]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. |
3 | * | |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b | 29 | */ |
1c79356b A |
30 | |
31 | #include "../../hfs_macos_defs.h" | |
32 | #include "../../hfs_format.h" | |
33 | ||
34 | #include "../headers/FileMgrInternal.h" | |
35 | #include "../headers/HFSUnicodeWrappers.h" | |
36 | #include "../headers/CatalogPrivate.h" | |
37 | ||
38 | ||
39 | struct ExtentsRecBuffer { | |
9bccf70c | 40 | ExtentKey extentKey; |
1c79356b A |
41 | ExtentRecord extentData; |
42 | }; | |
43 | typedef struct ExtentsRecBuffer ExtentsRecBuffer; | |
44 | ||
45 | ||
91447636 A |
46 | static UInt32 CheckExtents( void *extents, UInt32 blocks, Boolean isHFSPlus ); |
47 | static OSErr DeleteExtents( ExtendedVCB *vcb, UInt32 fileNumber, Boolean isHFSPlus ); | |
48 | static OSErr MoveExtents( ExtendedVCB *vcb, UInt32 srcFileID, UInt32 destFileID, Boolean isHFSPlus ); | |
49 | static void CopyCatalogNodeInfo( CatalogRecord *src, CatalogRecord *dest ); | |
50 | static void CopyBigCatalogNodeInfo( CatalogRecord *src, CatalogRecord *dest ); | |
51 | static void CopyExtentInfo( ExtentKey *key, ExtentRecord *data, ExtentsRecBuffer *buffer, UInt16 bufferCount ); | |
1c79356b A |
52 | |
53 | ||
54 | ||
55 | OSErr ExchangeFileIDs( ExtendedVCB *vcb, ConstUTF8Param srcName, ConstUTF8Param destName, HFSCatalogNodeID srcID, HFSCatalogNodeID destID, UInt32 srcHint, UInt32 destHint ) | |
56 | { | |
9bccf70c A |
57 | CatalogKey srcKey; // 518 bytes |
58 | CatalogKey destKey; // 518 bytes | |
1c79356b | 59 | CatalogRecord srcData; // 520 bytes |
1c79356b A |
60 | CatalogRecord destData; // 520 bytes |
61 | CatalogRecord swapData; // 520 bytes | |
9bccf70c A |
62 | SInt16 numSrcExtentBlocks; |
63 | SInt16 numDestExtentBlocks; | |
64 | OSErr err; | |
65 | Boolean isHFSPlus = ( vcb->vcbSigWord == kHFSPlusSigWord ); | |
1c79356b | 66 | |
0b4e3aa0 | 67 | err = BuildCatalogKeyUTF8(vcb, srcID, srcName, kUndefinedStrLen, &srcKey, NULL); |
1c79356b A |
68 | ReturnIfError(err); |
69 | ||
0b4e3aa0 | 70 | err = BuildCatalogKeyUTF8(vcb, destID, destName, kUndefinedStrLen, &destKey, NULL); |
1c79356b A |
71 | ReturnIfError(err); |
72 | ||
73 | if ( isHFSPlus ) | |
74 | { | |
75 | //-- Step 1: Check the catalog nodes for extents | |
76 | ||
77 | //-- locate the source file, test for extents in extent file, and copy the cat record for later | |
78 | err = LocateCatalogNodeByKey( vcb, srcHint, &srcKey, &srcData, &srcHint ); | |
79 | ReturnIfError( err ); | |
80 | ||
81 | if ( srcData.recordType != kHFSPlusFileRecord ) | |
82 | return( cmFThdDirErr ); // Error "cmFThdDirErr = it is a directory" | |
83 | ||
84 | //-- Check if there are any extents in the source file | |
85 |