1 // ------------------------------------------------------------------------------------------------ 2 // MODULE : FileUtils 3 // LANGAGE : C++ 4 // CREATEUR : Laurent ALBERT 5 // DATE : Friday, January 27, 1995 6 // DESCRIPTION : 7 // COMMENTAIRE : 8 // SCCSID : @(#)fileutil.h 1.1 11:50:00 18 Dec 1996 9 // ---------------------------------------------------------------------------- 10 // Copyright (c) 1999 Digital Imaging Group, Inc. 11 // For conditions of distribution and use, see copyright notice 12 // in Flashpix.h 13 // ---------------------------------------------------------------------------- 14 // ------------------------------------------------------------------------------------------------ 15 #ifndef FileUtils_h 16 #define FileUtils_h 17 #ifndef ApplCommun_h 18 #include "common_a.h" 19 #endif 20 // ------------------------------------------------------------------------------------------------ 21 22 // Includes 23 // -------- 24 25 #include <StandardFile.h> 26 27 // Constantes 28 // ---------- 29 30 // Declarations des classes 31 // ------------------------ 32 33 /* 34 ** Macros to get information out of GetVolParmsInfoBuffer 35 */ 36 37 #define isNetworkVolume(volParms) ((volParms).vMServerAdr != 0) 38 #define hasLimitFCBs(volParms) (((volParms).vMAttrib & (1L << bLimitFCBs)) != 0) 39 #define hasLocalWList(volParms) (((volParms).vMAttrib & (1L << bLocalWList)) != 0) 40 #define hasNoMiniFndr(volParms) (((volParms).vMAttrib & (1L << bNoMiniFndr)) != 0) 41 #define hasNoVNEdit(volParms) (((volParms).vMAttrib & (1L << bNoVNEdit)) != 0) 42 #define hasNoLclSync(volParms) (((volParms).vMAttrib & (1L << bNoLclSync)) != 0) 43 #define hasTrshOffLine(volParms) (((volParms).vMAttrib & (1L << bTrshOffLine)) != 0) 44 #define hasNoSwitchTo(volParms) (((volParms).vMAttrib & (1L << bNoSwitchTo)) != 0) 45 #define hasNoDeskItems(volParms) (((volParms).vMAttrib & (1L << bNoDeskItems)) != 0) 46 #define hasNoBootBlks(volParms) (((volParms).vMAttrib & (1L << bNoBootBlks)) != 0) 47 #define hasAccessCntl(volParms) (((volParms).vMAttrib & (1L << bAccessCntl)) != 0) 48 #define hasNoSysDir(volParms) (((volParms).vMAttrib & (1L << bNoSysDir)) != 0) 49 #define hasExtFSVol(volParms) (((volParms).vMAttrib & (1L << bHasExtFSVol)) != 0) 50 #define hasOpenDeny(volParms) (((volParms).vMAttrib & (1L << bHasOpenDeny)) != 0) 51 #define hasCopyFile(volParms) (((volParms).vMAttrib & (1L << bHasCopyFile)) != 0) 52 #define hasMoveRename(volParms) (((volParms).vMAttrib & (1L << bHasMoveRename)) != 0) 53 #define hasDesktopMgr(volParms) (((volParms).vMAttrib & (1L << bHasDesktopMgr)) != 0) 54 #define hasShortName(volParms) (((volParms).vMAttrib & (1L << bHasShortName)) != 0) 55 #define hasFolderLock(volParms) (((volParms).vMAttrib & (1L << bHasFolderLock)) != 0) 56 #define hasPersonalAccessPrivileges(volParms) \ 57 (((volParms).vMAttrib & (1L << bHasPersonalAccessPrivileges)) != 0) 58 #define hasUserGroupList(volParms) (((volParms).vMAttrib & (1L << bHasUserGroupList)) != 0) 59 #define hasCatSearch(volParms) (((volParms).vMAttrib & (1L << bHasCatSearch)) != 0) 60 #define hasFileIDs(volParms) (((volParms).vMAttrib & (1L << bHasFileIDs)) != 0) 61 #define hasBTreeMgr(volParms) (((volParms).vMAttrib & (1L << bHasBTreeMgr)) != 0) 62 #define hasBlankAccessPrivileges(volParms) \ 63 (((volParms).vMAttrib & (1L << bHasBlankAccessPrivileges)) != 0) 64 65 /* 66 ** Deny mode permissions for use with the HOpenAware, HOpenRFAware, 67 ** FSpOpenAware, and FSpOpenRFAware functions. 68 */ 69 70 enum 71 { 72 dmNone = 0x0000, 73 dmNoneDenyRd = 0x0010, 74 dmNoneDenyWr = 0x0020, 75 dmNoneDenyRdWr = 0x0030, 76 dmRd = 0x0001, /* Single writer, multiple readers; the readers */ 77 dmRdDenyRd = 0x0011, 78 dmRdDenyWr = 0x0021, /* Browsing - equivalent to fsRdPerm */ 79 dmRdDenyRdWr = 0x0031, 80 dmWr = 0x0002, 81 dmWrDenyRd = 0x0012, 82 dmWrDenyWr = 0x0022, 83 dmWrDenyRdWr = 0x0032, 84 dmRdWr = 0x0003, /* Shared access - equivalent to fsRdWrShPerm */ 85 dmRdWrDenyRd = 0x0013, 86 dmRdWrDenyWr = 0x0023, /* Single writer, multiple readers; the writer */ 87 dmRdWrDenyRdWr = 0x0033 /* Exclusive access - equivalent to fsRdWrPerm */ 88 }; 89 90 91 // Definitions des classes 92 // ----------------------- 93 94 /*****************************************************************************/ 95 96 pascal OSErr FileCopy(short srcVRefNum, 97 long srcDirID, 98 ConstStr255Param srcName, 99 short dstVRefNum, 100 long dstDirID, 101 StringPtr dstPathname, 102 StringPtr copyName, 103 Ptr copyBufferPtr, 104 long copyBufferSize, 105 Boolean preflight); 106 /* � Duplicate a file and optionally rename it. 107 The FileCopy function duplicates a file and optionally renames it. 108 Since the PBHCopyFile routine is only available on some 109 AFP server volumes under specific conditions, this routine 110 either uses PBHCopyFile, or does all of the work PBHCopyFile 111 does. The srcVRefNum, srcDirID and srcName are used to 112 determine the location of the file to copy. The dstVRefNum 113 dstDirID and dstPathname are used to determine the location of 114 the destination directory. If copyName <> NIL, then it points 115 to the name of the new file. If copyBufferPtr <> NIL, it 116 points to a buffer of copyBufferSize that is used to copy 117 the file's data. The larger the supplied buffer, the 118 faster the copy. If copyBufferPtr = NIL, then this routine 119 allocates a buffer in the application heap. If you pass a 120 copy buffer to this routine, make its size a multiple of 512 121 ($200) bytes for optimum performance. 122 123 srcVRefNum input: Source volume specification. 124 srcDirID input: Source directory ID. 125 srcName input: Source file name. 126 dstVRefNum input: Destination volume specification. 127 dstDirID input: Destination directory ID. 128 dstPathname input: Pointer to destination directory name, or 129 nil when dstDirID specifies a directory. 130 copyName input: Points to the new file name if the file is 131 to be renamed or nil if the file isn't to 132 be renamed. 133 copyBufferPtr input: Points to a buffer of copyBufferSize that 134 is used the i/o buffer for the copy or 135 nil if you want FileCopy to allocate its 136 own buffer in the application heap. 137 copyBufferSize input: The size of the buffer pointed to 138 by copyBufferPtr. 139 preflight input: If true, FileCopy makes sure there are enough 140 allocation blocks on the destination volume to 141 hold both the data and resource forks before 142 starting the copy. 143 144 __________ 145 146 Also see: FSpFileCopy, DirectoryCopy, FSpDirectoryCopy 147 */ 148 149 /*****************************************************************************/ 150 151 pascal OSErr FSpFileCopy(const FSSpec *srcSpec, 152 const FSSpec *dstSpec, 153 StringPtr copyName, 154 Ptr copyBufferPtr, 155 long copyBufferSize, 156 Boolean preflight); 157 /* � Duplicate a file and optionally rename it. 158 The FSpFileCopy function duplicates a file and optionally renames it. 159 Since the PBHCopyFile routine is only available on some 160 AFP server volumes under specific conditions, this routine 161 either uses PBHCopyFile, or does all of the work PBHCopyFile 162 does. The srcSpec is used to 163 determine the location of the file to copy. The dstSpec is 164 used to determine the location of the 165 destination directory. If copyName <> NIL, then it points 166 to the name of the new file. If copyBufferPtr <> NIL, it 167 points to a buffer of copyBufferSize that is used to copy 168 the file's data. The larger the supplied buffer, the 169 faster the copy. If copyBufferPtr = NIL, then this routine 170 allocates a buffer in the application heap. If you pass a 171 copy buffer to this routine, make its size a multiple of 512 172 ($200) bytes for optimum performance. 173 174 srcSpec input: An FSSpec record specifying the source file. 175 dstSpec input: An FSSpec record specifying the destination 176 directory. 177 copyName input: Points to the new file name if the file is 178 to be renamed or nil if the file isn't to 179 be renamed. 180 copyBufferPtr input: Points to a buffer of copyBufferSize that 181 is used the i/o buffer for the copy or 182 nil if you want FileCopy to allocate its 183 own buffer in the application heap. 184 copyBufferSize input: The size of the buffer pointed to 185 by copyBufferPtr. 186 preflight input: If true, FSpFileCopy makes sure there are 187 enough allocation blocks on the destination 188 volume to hold both the data and resource forks 189 before starting the copy. 190 191 __________ 192 193 Also see: FileCopy, DirectoryCopy, FSpDirectoryCopy 194 */ 195 196 /*****************************************************************************/ 197 198 pascal OSErr FSpRenameCompat(FSSpec *spec, 199 ConstStr255Param newName); 200 /* � Rename a file or directory. 201 The FSpRenameCompat function renames a file or directory. 202 203 spec input: An FSSpec record specifying the file. 204 newName input: The new name of the file or directory. 205 */ 206 207 /*****************************************************************************/ 208 209 pascal OSErr HMoveRename(short vRefNum, 210 long srcDirID, 211 ConstStr255Param srcName, 212 long dstDirID, 213 StringPtr dstpathName, 214 StringPtr copyName); 215 /* � Move a file or directory on a file server and optionally to rename it. 216 The HMoveRename function moves a file or directory and optionally 217 renames it. The source and destination locations must be on the same 218 shared volume. 219 220 vRefNum input: Volume specification. 221 srcDirID input: Source directory ID. 222 srcName input: The source object name. 223 dstDirID input: Destination directory ID. 224 dstName input: Pointer to destination directory name, or 225 nil when dstDirID specifies a directory. 226 copyName input: Points to the new name if the object is to be 227 renamed or nil if the object isn't to be renamed. 228 229 __________ 230 231 Also see: FSpMoveRename, HMoveRenameCompat, FSpMoveRenameCompat 232 */ 233 234 /*****************************************************************************/ 235 236 pascal OSErr GetFilenameFromPathname(ConstStr255Param pathname, 237 Str255 filename); 238 /* � Get the object name from the end of a full or partial pathname. 239 The GetFilenameFromPathname function gets the file (or directory) name 240 from the end of a full or partial pathname. Returns notAFileErr if the 241 pathname is nil, the pathname is empty, or the pathname cannot refer to 242 a filename (with a noErr result, the pathname could still refer to a 243 directory). 244 245 pathname input: A full or partial pathname. 246 filename output: The file (or directory) name. 247 248 __________ 249 250 See also: GetObjectLocation. 251 */ 252 253 /*****************************************************************************/ 254 255 pascal OSErr GetObjectLocation(short vRefNum, 256 long dirID, 257 StringPtr pathname, 258 short *realVRefNum, 259 long *realParID, 260 Str255 realName, 261 Boolean *isDirectory); 262 /* � Get a file system object's location. 263 The GetObjectLocation function gets a file system object's location - 264 that is, its real volume reference number, real parent directory ID, 265 and name. While we're at it, determine if the object is a file or directory. 266 If GetObjectLocation returns fnfErr, then the location information 267 returned is valid, but it describes an object that doesn't exist. 268 You can use the location information for another operation, such as 269 creating a file or directory. 270 271 vRefNum input: Volume specification. 272 dirID input: Directory ID. 273 pathname input: Pointer to object name, or nil when dirID specifies 274 a directory that's the object. 275 realVRefNum output: The real volume reference number. 276 realParID output: The parent directory ID of the specified object. 277 realName output: The name of the specified object (the case of the 278 object name may not be the same as the object's 279 catalog entry on disk - since the Macintosh file 280 system is not case sensitive, it shouldn't matter). 281 isDirectory output: True if object is a directory; false if object 282 is a file. 283 284 __________ 285 286 See also: FSMakeFSSpecCompat 287 */ 288 /*****************************************************************************/ 289 290 pascal OSErr HMoveRenameCompat(short vRefNum, 291 long srcDirID, 292 ConstStr255Param srcName, 293 long dstDirID, 294 StringPtr dstpathName, 295 StringPtr copyName); 296 /* � Move a file or directory and optionally rename it. 297 The HMoveRenameCompat function moves a file or directory and optionally 298 renames it. The source and destination locations must be on the same 299 volume. This routine works even if the volume doesn't support MoveRename. 300 301 vRefNum input: Volume specification. 302 srcDirID input: Source directory ID. 303 srcName input: The source object name. 304 dstDirID input: Destination directory ID. 305 dstName input: Pointer to destination directory name, or 306 nil when dstDirID specifies a directory. 307 copyName input: Points to the new name if the object is to be 308 renamed or nil if the object isn't to be renamed. 309 310 __________ 311 312 See also: FSpMoveRenameCompat 313 */ 314 315 /*****************************************************************************/ 316 317 pascal OSErr FSpMoveRenameCompat(const FSSpec *srcSpec, 318 const FSSpec *dstSpec, 319 StringPtr copyName); 320 /* � Move a file or directory and optionally rename it. 321 The FSpMoveRenameCompat function moves a file or directory and optionally 322 renames it. The source and destination locations must be on the same 323 volume. This routine works even if the volume doesn't support MoveRename. 324 325 srcSpec input: An FSSpec record specifying the source object. 326 dstSpec input: An FSSpec record specifying the destination 327 directory. 328 copyName input: Points to the new name if the object is to be 329 renamed or nil if the object isn't to be renamed. 330 331 __________ 332 333 See also: HMoveRenameCompat 334 */ 335 336 /*****************************************************************************/ 337 338 pascal OSErr HGetDirAccess(short vRefNum, 339 long dirID, 340 StringPtr name, 341 long *ownerID, 342 long *groupID, 343 long *accessRights); 344 /* � Get a directory's access control information on a shared volume. 345 The HGetDirAccess function retrieves the directory access control 346 information for a directory on a shared volume. 347 348 vRefNum input: Volume specification. 349 dirID input: Directory ID. 350 name input: Pointer to directory name, or nil if dirID 351 specifies the directory. 352 ownerID output: The directory's owner ID. 353 groupID output: The directory's group ID or 354 0 if no group affiliation. 355 accessRights output: The directory's access rights. 356 357 __________ 358 359 Also see: HGetLogInInfo, FSpGetDirAccess, HSetDirAccess, 360 FSpSetDirAccess, HMapName, HMapID 361 */ 362 363 /*****************************************************************************/ 364 365 pascal OSErr FSpGetDirAccess(const FSSpec *spec, 366 long *ownerID, 367 long *groupID, 368 long *accessRights); 369 /* � Get a directory's access control information on a shared volume. 370 The FSpGetDirAccess function retrieves the directory access control 371 information for a directory on a shared volume. 372 373 spec input: An FSSpec record specifying the directory. 374 ownerID output: The directory's owner ID. 375 groupID output: The directory's group ID or 376 0 if no group affiliation. 377 accessRights output: The directory's access rights. 378 379 __________ 380 381 Also see: HGetLogInInfo, HGetDirAccess, HSetDirAccess, 382 FSpSetDirAccess, HMapName, HMapID 383 */ 384 385 /*****************************************************************************/ 386 387 pascal OSErr HSetDirAccess(short vRefNum, 388 long dirID, 389 StringPtr name, 390 long ownerID, 391 long groupID, 392 long accessRights); 393 /* � Set a directory's access control information on a shared volume. 394 The HSetDirAccess function changes the directory access control 395 information for a directory on a shared volume. You must own a directory 396 to change its access control information. 397 398 vRefNum input: Volume specification. 399 dirID input: Directory ID. 400 name input: Pointer to directory name, or nil if dirID 401 specifies the directory. 402 ownerID input: The directory's owner ID. 403 groupID input: The directory's group ID or 404 0 if no group affiliation. 405 accessRights input: The directory's access rights. 406 407 __________ 408 409 Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, 410 FSpSetDirAccess, HMapName, HMapID 411 */ 412 413 /*****************************************************************************/ 414 415 pascal OSErr FSpSetDirAccess(const FSSpec *spec, 416 long ownerID, 417 long groupID, 418 long accessRights); 419 /* � Set a directory's access control information on a shared volume. 420 The FSpSetDirAccess function changes the directory access control 421 information for a directory on a shared volume. You must own a directory 422 to change its access control information. 423 424 spec input: An FSSpec record specifying the directory. 425 ownerID input: The directory's owner ID. 426 groupID input: The directory's group ID or 427 0 if no group affiliation. 428 accessRights input: The directory's access rights. 429 430 __________ 431 432 Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess, 433 HMapName, HMapID 434 */ 435 436 /*****************************************************************************/ 437 438 // Fonctions 'inline' 439 // ------------------ 440 441 // Fonctions 'extern' 442 // ------------------ 443 444 // Variables 'extern' 445 // ------------------ 446 447 // ------------------------------------------------------------------------------------------------ 448 #endif // FileUtils_h 449 // ------------------------------------------------------------------------------------------------ 450