File: file.h

package info (click to toggle)
open-vm-tools 1%3A8.4.2-261024-1%2Bbuild1
  • links: PTS, VCS
  • area: contrib
  • in suites: squeeze-lts
  • size: 20,376 kB
  • ctags: 30,043
  • sloc: ansic: 164,785; sh: 10,713; cpp: 6,525; makefile: 3,386
file content (301 lines) | stat: -rw-r--r-- 9,943 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/*********************************************************
 * Copyright (C) 1998 VMware, Inc. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation version 2.1 and no later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
 *
 *********************************************************/

/*
 * file.h --
 *
 *	Interface to host file system and related utility functions.
 */

#ifndef _FILE_H_
#define _FILE_H_

#ifdef __cplusplus
extern "C"{
#endif

#include <stdio.h>
#define INCLUDE_ALLOW_USERLEVEL
#define INCLUDE_ALLOW_VMCORE
#include "includeCheck.h"

#include "fileIO.h"
#include "unicodeTypes.h"

#ifdef N_PLAT_NLM
#define FILE_MAXPATH	256
#elif defined(_WIN32)
#define FILE_MAXPATH	MAX_PATH
#else
# ifdef __FreeBSD__
#  include <sys/param.h> // For __FreeBSD_version
# endif
# if defined(__FreeBSD__)
#  include <sys/syslimits.h>  // PATH_MAX
# else 
#  include <limits.h>  // PATH_MAX
# endif 
#define FILE_MAXPATH	PATH_MAX
#endif

#define FILE_SEARCHPATHTOKEN ";"


/*
 * Opaque, platform-specific stucture for supporting the directory walking API.
 */

typedef struct WalkDirContextImpl WalkDirContextImpl;
typedef const WalkDirContextImpl *WalkDirContext;

#if defined(__APPLE__)
typedef enum {
   FILEMACOS_UNMOUNT_SUCCESS,
   FILEMACOS_UNMOUNT_SUCCESS_ALREADY,
   FILEMACOS_UNMOUNT_ERROR,
} FileMacosUnmountStatus;

EXTERN FileMacosUnmountStatus FileMacos_UnmountDev(char const *bsdDev,
                                                   Bool wholeDev,
                                                   Bool eject,
                                                   Bool su);

EXTERN void FileMacos_MountDevAsyncNoResult(char const *bsdDev,
                                            Bool su);

EXTERN Bool FileMacos_IsOnExternalDevice(int fd);
EXTERN Bool FileMacos_IsOnSparseDmg(int fd);
EXTERN Bool FileMacos_IsSliceDevice(char const *bsdDev);

EXTERN char *FileMacos_DiskDevToUserFriendlyName(char const *bsdDiskDev);

EXTERN char *FileMacos_DiskDeviceToUniqueID(char const *bsdPath);
EXTERN char *FileMacos_UniqueIDToDiskDevice(char const *identifier);
#elif defined VMX86_SERVER
EXTERN int File_GetVMFSBlockSize(ConstUnicode pathName, uint32 *blockSize);
EXTERN int File_GetVMFSfsType(ConstUnicode pathName, char **fsType);
#endif

EXTERN Bool File_Exists(ConstUnicode pathName);

EXTERN int File_Unlink(ConstUnicode pathName);

EXTERN int File_UnlinkIfExists(ConstUnicode pathName);

EXTERN int File_UnlinkDelayed(ConstUnicode pathName);

EXTERN int File_UnlinkNoFollow(ConstUnicode pathName);

EXTERN void File_SplitName(ConstUnicode pathName,
                           Unicode *volume, 
                           Unicode *dir, 
                           Unicode *base);

EXTERN void File_GetPathName(ConstUnicode fullPath, 
                             Unicode *pathName, 
                             Unicode *base);

EXTERN Unicode File_StripSlashes(ConstUnicode path);

EXTERN Unicode File_PathJoin(ConstUnicode dirName,
                             ConstUnicode baseName);

EXTERN Bool File_CreateDirectory(ConstUnicode pathName);
EXTERN Bool File_EnsureDirectory(ConstUnicode pathName);

EXTERN Bool File_DeleteEmptyDirectory(ConstUnicode pathName);

EXTERN Bool File_CreateDirectoryHierarchy(ConstUnicode pathName);

EXTERN Bool File_DeleteDirectoryTree(ConstUnicode pathName);

EXTERN int File_ListDirectory(ConstUnicode pathName,
                              Unicode **ids);

/*
 * Simple file-system walk.
 */

EXTERN WalkDirContext File_WalkDirectoryStart(ConstUnicode parentPath);
EXTERN Bool File_WalkDirectoryNext(WalkDirContext context,
                                   Unicode *path);
EXTERN void File_WalkDirectoryEnd(WalkDirContext context);

EXTERN Bool File_IsDirectory(ConstUnicode pathName);

EXTERN Bool File_IsFile(ConstUnicode pathName);

EXTERN Bool File_IsSymLink(ConstUnicode fileName);

EXTERN Bool File_IsCharDevice(ConstUnicode pathName);

EXTERN Bool File_IsRemote(ConstUnicode pathName);

EXTERN Bool File_IsEmptyDirectory(ConstUnicode pathName);

EXTERN Unicode File_Cwd(ConstUnicode drive); // XXX belongs to `process' module

EXTERN Unicode File_FullPath(ConstUnicode pathName);

EXTERN Bool File_IsFullPath(ConstUnicode pathName);

EXTERN uint64 File_GetFreeSpace(ConstUnicode pathName,
                                Bool doNotAscend);

EXTERN uint64 File_GetCapacity(ConstUnicode pathName);

/* Deprecated; use Util_GetSafeTmpDir if you can */
EXTERN char *File_GetTmpDir(Bool useConf);

/* Deprecated; use Util_MakeSafeTemp if you can */
EXTERN int File_MakeTemp(ConstUnicode tag,
                         Unicode *presult);

EXTERN int File_MakeTempEx(ConstUnicode dir,
                           ConstUnicode fileName,
                           Unicode *presult);

EXTERN int64 File_GetModTime(ConstUnicode pathName);

EXTERN char *File_GetModTimeString(ConstUnicode pathName);

EXTERN char *File_GetUniqueFileSystemID(const char *fileName);

EXTERN Bool File_GetTimes(ConstUnicode pathName,
                          VmTimeType *createTime,
                          VmTimeType *accessTime,
                          VmTimeType *writeTime,
                          VmTimeType *attrChangeTime);

EXTERN Bool File_SetTimes(ConstUnicode pathName,
                          VmTimeType createTime,
                          VmTimeType accessTime,
                          VmTimeType writeTime,
                          VmTimeType attrChangeTime);

EXTERN Bool File_GetFilePermissions(ConstUnicode pathName,
                                   int *mode);

EXTERN Bool File_SetFilePermissions(ConstUnicode pathName,
                                    int mode);

EXTERN Bool File_SupportsFileSize(ConstUnicode pathName,
                                  uint64 fileSize);

EXTERN Bool File_SupportsLargeFiles(ConstUnicode pathName);

EXTERN Bool File_CopyFromFdToFd(FileIODescriptor src, 
                                FileIODescriptor dst);

EXTERN FileIOResult File_CreatePrompt(FileIODescriptor *file, 
                                      ConstUnicode pathName, 
                                      int access, 
                                      int prompt);

EXTERN Bool File_CopyFromFd(FileIODescriptor src, 
                            ConstUnicode dstName, 
                            Bool overwriteExisting);

EXTERN Bool File_Copy(ConstUnicode srcName, 
                      ConstUnicode dstName, 
                      Bool overwriteExisting);

EXTERN Bool File_CopyFromFdToName(FileIODescriptor src, 
                                  ConstUnicode dstName, 
                                  int dstDispose);

EXTERN Bool File_CopyFromNameToName(ConstUnicode srcName, 
                                    ConstUnicode dstName, 
                                    int dstDispose);

EXTERN Bool File_Replace(ConstUnicode oldFile, 
                         ConstUnicode newFile);

EXTERN Bool File_Rename(ConstUnicode oldFile, 
                        ConstUnicode newFile);

EXTERN int64 File_GetSize(ConstUnicode pathName);

EXTERN int64 File_GetSizeByPath(ConstUnicode pathName);

EXTERN int64 File_GetSizeAlternate(ConstUnicode pathName);

/* file change notification module */
typedef void (*CbFunction)(void *clientData);

typedef void (*NotifyCallback)(ConstUnicode pathName, 
                               int err, 
                               void *data);

typedef void (*PollTimeout) (CbFunction f,
                             void *clientData,
                             int delay);

typedef void (*PollRemoveTimeout) (CbFunction f,
                                   void *clientData);

EXTERN void File_PollInit(PollTimeout pt, 
                          PollRemoveTimeout prt);

EXTERN void File_PollExit(void);

EXTERN void File_PollImpersonateOnCheck(Bool check);

EXTERN Bool File_PollAddFile(ConstUnicode pathName, 
                             uint32 pollPeriod, 
                             NotifyCallback callback, 
                             void *data, 
                             Bool fPeriodic);

EXTERN Bool File_PollAddDirFile(ConstUnicode pathName,
                                uint32 pollPeriod, 
                                NotifyCallback callback,
                                void *data, 
                                Bool fPeriodic);

EXTERN Bool File_PollRemoveFile(ConstUnicode pathName, 
                                uint32 pollPeriod,
                                NotifyCallback callback);

EXTERN Bool File_IsSameFile(ConstUnicode path1,
                            ConstUnicode path2);

EXTERN char *File_PrependToPath(const char *searchPath,
                                const char *elem);

EXTERN Bool File_FindFileInSearchPath(const char *file,
                                      const char *searchPath,
                                      const char *cwd,
                                      char **result);

EXTERN Unicode File_ReplaceExtension(ConstUnicode pathName,
                                     ConstUnicode newExtension,
                                     uint32 numExtensions,
                                     ...);

EXTERN Bool File_OnVMFS(ConstUnicode pathName);

EXTERN Bool File_MakeCfgFileExecutable(ConstUnicode pathName);

EXTERN char *File_ExpandAndCheckDir(const char *dirName);

#ifdef __cplusplus
} // extern "C" {
#endif

#endif // ifndef _FILE_H_