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