VirtualBox

source: vbox/trunk/src/VBox/Main/include/GuestFileImpl.h@ 61644

Last change on this file since 61644 was 55631, checked in by vboxsync, 10 years ago

IGuestSession:

  • Added pathStyle attribute and associated enum.
  • Added a currentDirectory attribute (stub).
  • Introduced fsObjExists (earlier fsExists) which works on all fs obj types.
  • Combined directoryQueryInfo and fileQueryInfo into fsObjQueryInfo (earlier fsQueryInfo) which works on all fs obj types. Caller can check the type attribute.
  • Combined fileRemove and symlinkRemove* into fsObjRemove both on suggestion from Michael and because it's impossible to implement correctly with introducing races. Besides, our implementation was already doing the fsObjRemove job, no type checks.
  • Combined directoryRename, fileRename and symlinkRename into fsObjRename since we cannot implement type specific renames without introducing races on all platforms, and again, the current implementation already does the whole shebang.
  • Combined directorySetACL and fileSetACL into fsObjSetACL, adding a UNIX-style mode parameter for use when the ACL string is empty.
  • Stubbed the recursive directory copy methods directoryCopy, directoryCopyToGuest, and directoryCopyFromGuest. These replaces the proposed FileCopyFlag::Recursive flag.
  • Stubbed a generic move-anything-inside-the-guest method, fsObjMove, for future explotations. (Considered this on file/dir level, but it's the rename and type race problem. So, did the 'mv' approach instead.)
  • Renamed CopyFileFlag to FileCopyFlag.
  • Prefixed copyTo and copyFrom with 'file' and added 'Guest' postfix to clarify the direction (now: fileCopyToGuest, fileCopyFromGuest).
  • Added fileCopy method for copy a guest file to another guest location.
  • directoryExists got a followSymlinks parameter.
  • fileExist and fileQuerySize all got a followSymlinks parameter.
  • Retired directoryRename in favor of fsObjRename.
  • Retired directorySetACL in favor of fsObjSetACL.
  • Retired fileSetACL in favor of fsObjSetACL.
  • Retired fileRemove in favor of fsObjRemove - fileRemove was already removing everything except directories, no need for ambiguous duplications.
  • Retired symlinkRemoveDirectory and symlinkRemoveFile in favor of fsObjRemove.
  • replaced the openMode string parameter int fileOpen[Ex] methods with an enum FileAccessMode (we made some wrong design choices way back).
  • replaced the disposition string parameter in fileOpen[Ex] methods with an enum FileOpenAction. This one was more obvious, should've seen this way back.
  • replaced the sharingMode stirng parameter in the fileOpenEx method with an enum FileSharingMode.
  • Documented directoryRemoveRecursive flags issue.


IFile,IGuestFile:

  • Stubbed querySize
  • Stubbed setSize.
  • Renamed FileSeekType to FileSeekOrigin.
  • Implemented seek() relative to end, flag was forgotten.
  • Made seek() return the new offset.
  • Extended setACL with a UNIX-style file mode argument that should be used if the ACL string is empty (this way we can actually get something implemented without 2 months of cross platform ACL research).
  • The openMode and disposition attributes has been updated to match the fileOpenEx enum changes.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: GuestFileImpl.h 55631 2015-05-04 04:08:10Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Guest file handling implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2014 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_GUESTFILEIMPL
19#define ____H_GUESTFILEIMPL
20
21#include "VirtualBoxBase.h"
22#include "EventImpl.h"
23
24#include "GuestCtrlImplPrivate.h"
25#include "GuestFileWrap.h"
26
27class Console;
28class GuestSession;
29class GuestProcess;
30
31class ATL_NO_VTABLE GuestFile :
32 public GuestFileWrap,
33 public GuestObject
34{
35public:
36 /** @name COM and internal init/term/mapping cruft.
37 * @{ */
38 DECLARE_EMPTY_CTOR_DTOR(GuestFile)
39
40 int init(Console *pConsole, GuestSession *pSession, ULONG uFileID, const GuestFileOpenInfo &openInfo);
41 void uninit(void);
42
43 HRESULT FinalConstruct(void);
44 void FinalRelease(void);
45 /** @} */
46
47public:
48 /** @name Public internal methods.
49 * @{ */
50 int i_callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
51 int i_closeFile(int *pGuestRc);
52 EventSource *i_getEventSource(void) { return mEventSource; }
53 static Utf8Str i_guestErrorToString(int guestRc);
54 int i_onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
55 int i_onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
56 int i_onRemove(void);
57 int i_openFile(uint32_t uTimeoutMS, int *pGuestRc);
58 int i_readData(uint32_t uSize, uint32_t uTimeoutMS, void* pvData, uint32_t cbData, uint32_t* pcbRead);
59 int i_readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS,
60 void* pvData, size_t cbData, size_t* pcbRead);
61 int i_seekAt(int64_t iOffset, GUEST_FILE_SEEKTYPE eSeekType, uint32_t uTimeoutMS, uint64_t *puOffset);
62 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
63 int i_setFileStatus(FileStatus_T fileStatus, int fileRc);
64 int i_waitForOffsetChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint64_t *puOffset);
65 int i_waitForRead(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbRead);
66 int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, FileStatus_T *pFileStatus, int *pGuestRc);
67 int i_waitForWrite(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint32_t *pcbWritten);
68 int i_writeData(uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
69 int i_writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten);
70 /** @} */
71
72private:
73
74 /** @name Wrapped IGuestFile properties.
75 * @{ */
76 HRESULT getCreationMode(ULONG *aCreationMode);
77 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
78 HRESULT getId(ULONG *aId);
79 HRESULT getInitialSize(LONG64 *aInitialSize);
80 HRESULT getOffset(LONG64 *aOffset);
81 HRESULT getStatus(FileStatus_T *aStatus);
82 HRESULT getFileName(com::Utf8Str &aFileName);
83 HRESULT getAccessMode(FileAccessMode_T *aAccessMode);
84 HRESULT getOpenAction(FileOpenAction_T *aOpenAction);
85 /** @} */
86
87 /** @name Wrapped IGuestFile methods.
88 * @{ */
89 HRESULT close();
90 HRESULT queryInfo(ComPtr<IFsObjInfo> &aObjInfo);
91 HRESULT querySize(LONG64 *aSize);
92 HRESULT read(ULONG aToRead,
93 ULONG aTimeoutMS,
94 std::vector<BYTE> &aData);
95 HRESULT readAt(LONG64 aOffset,
96 ULONG aToRead,
97 ULONG aTimeoutMS,
98 std::vector<BYTE> &aData);
99 HRESULT seek(LONG64 aOffset,
100 FileSeekOrigin_T aWhence,
101 LONG64 *aNewOffset);
102 HRESULT setACL(const com::Utf8Str &aAcl,
103 ULONG aMode);
104 HRESULT setSize(LONG64 aSize);
105 HRESULT write(const std::vector<BYTE> &aData,
106 ULONG aTimeoutMS,
107 ULONG *aWritten);
108 HRESULT writeAt(LONG64 aOffset,
109 const std::vector<BYTE> &aData,
110 ULONG aTimeoutMS,
111 ULONG *aWritten);
112 /** @} */
113
114 /** This can safely be used without holding any locks.
115 * An AutoCaller suffices to prevent it being destroy while in use and
116 * internally there is a lock providing the necessary serialization. */
117 const ComObjPtr<EventSource> mEventSource;
118
119 struct Data
120 {
121 /** The file's open info. */
122 GuestFileOpenInfo mOpenInfo;
123 /** The file's initial size on open. */
124 uint64_t mInitialSize;
125 /** The file's ID. */
126 uint32_t mID;
127 /** The current file status. */
128 FileStatus_T mStatus;
129 /** The last returned process status
130 * returned from the guest side. */
131 int mLastError;
132 /** The file's current offset. */
133 uint64_t mOffCurrent;
134 } mData;
135};
136
137#endif /* !____H_GUESTFILEIMPL */
138
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette