VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/MoreFiles/FSCopyObject.h@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.7 KB
Line 
1/*
2 File: FSCopyObject.h
3
4 Contains: A Copy/Delete Files/Folders engine which uses the HFS+ API's
5
6 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
7 ("Apple") in consideration of your agreement to the following terms, and your
8 use, installation, modification or redistribution of this Apple software
9 constitutes acceptance of these terms. If you do not agree with these terms,
10 please do not use, install, modify or redistribute this Apple software.
11
12 In consideration of your agreement to abide by the following terms, and subject
13 to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
14 copyrights in this original Apple software (the "Apple Software"), to use,
15 reproduce, modify and redistribute the Apple Software, with or without
16 modifications, in source and/or binary forms; provided that if you redistribute
17 the Apple Software in its entirety and without modifications, you must retain
18 this notice and the following text and disclaimers in all such redistributions of
19 the Apple Software. Neither the name, trademarks, service marks or logos of
20 Apple Computer, Inc. may be used to endorse or promote products derived from the
21 Apple Software without specific prior written permission from Apple. Except as
22 expressly stated in this notice, no other rights or licenses, express or implied,
23 are granted by Apple herein, including but not limited to any patent rights that
24 may be infringed by your derivative works or by other works in which the Apple
25 Software may be incorporated.
26
27 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
28 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
29 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
31 COMBINATION WITH YOUR PRODUCTS.
32
33 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
34 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
35 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
37 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
38 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
39 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
41 Copyright © 2002 Apple Computer, Inc., All Rights Reserved
42*/
43
44
45#ifndef __FSCOPYOBJECT_H__
46#define __FSCOPYOBJECT_H__
47
48#include <Files.h>
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54#define DEBUG_COPY_OBJECT 0 // set to zero if you don't want debug spew
55
56#define QuoteExceptionString(x) #x
57
58#if DEBUG_COPY_OBJECT
59 #include <stdio.h>
60
61 #define mycheck_noerr(error) \
62 do { \
63 OSStatus localError = error; \
64 if (localError == noErr) ; \
65 else { \
66 printf(QuoteExceptionString(error) " != noErr in File: %s, Function: %s, Line: %d, Error: %d\n", \
67 __FILE__, __FUNCTION__, __LINE__, localError); \
68 } \
69 } while (false)
70
71 #define mycheck(assertion) \
72 do { \
73 if (assertion) ; \
74 else { \
75 printf(QuoteExceptionString(assertion) " failed in File: %s, Function: %s, Line: %d\n", \
76 __FILE__, __FUNCTION__, __LINE__); \
77 } \
78 } while (false)
79 #define myverify(assertion) mycheck(assertion)
80 #define myverify_noerr(assertion) mycheck_noerr( (assertion) )
81#else
82 #define mycheck(assertion)
83 #define mycheck_noerr(err)
84 #define myverify(assertion) do { (void) (assertion); } while (0)
85 #define myverify_noerr(assertion) myverify(assertion)
86#endif
87
88/*
89 This code is a combination of MoreFilesX (by Jim Luther) and MPFileCopy (by Quinn)
90 with some added features and bug fixes. This code will run in OS 9.1 and up
91 and 10.1.x (Classic and Carbon)
92*/
93
94/*****************************************************************************/
95
96#pragma mark CopyObjectFilterProcPtr
97
98/*
99 This is the prototype for the CallCopyObjectFilterProc function which
100 is called once for each file and directory found by FSCopyObject.
101 The CallCopyObjectFilterProc can use the read-only data it receives for
102 whatever it wants.
103
104 The result of the CallCopyObjectFilterProc function indicates if
105 iteration should be stopped. To stop iteration, return true; to continue
106 iteration, return false.
107
108 The yourDataPtr parameter can point to whatever data structure you might
109 want to access from within the CallCopyObjectFilterProc.
110
111 containerChanged --> Set to true if the container's contents changed
112 during iteration.
113 currentLevel --> The current recursion level into the container.
114 1 = the container, 2 = the container's immediate
115 subdirectories, etc.
116 currentOSErr --> The current error code, shows the results of the
117 copy of the current object (ref)
118 catalogInfo --> The catalog information for the current object.
119 Only the fields requested by the whichInfo
120 parameter passed to FSIterateContainer are valid.
121 ref --> The FSRef to the current object.
122 spec --> The FSSpec to the current object if the wantFSSpec
123 parameter passed to FSCopyObject is true.
124 name --> The name of the current object if the wantName
125 parameter passed to FSCopyObject is true.
126 yourDataPtr --> An optional pointer to whatever data structure you
127 might want to access from within the
128 CallCopyObjectFilterProc.
129 result <-- To stop iteration, return true; to continue
130 iteration, return false.
131
132 __________
133
134 Also see: FSCopyObject
135*/
136
137typedef CALLBACK_API( Boolean , CopyObjectFilterProcPtr ) (
138 Boolean containerChanged,
139 ItemCount currentLevel,
140 OSErr currentOSErr,
141 const FSCatalogInfo *catalogInfo,
142 const FSRef *ref,
143 const FSSpec *spec,
144 const HFSUniStr255 *name,
145 void *yourDataPtr);
146
147
148/*****************************************************************************/
149
150#pragma mark CallCopyObjectFilterProc
151
152#define CallCopyObjectFilterProc(userRoutine, containerChanged, currentLevel, currentOSErr, catalogInfo, ref, spec, name, yourDataPtr) \
153 (*(userRoutine))((containerChanged), (currentLevel), (currentOSErr), (catalogInfo), (ref), (spec), (name), (yourDataPtr))
154
155/*****************************************************************************/
156
157#pragma mark FSCopyObject
158
159/*
160 The FSCopyObject function takes a source object (can be a file or directory)
161 and copies it (and its contents if it's a directory) to the new destination
162 directory.
163
164 It will call your CopyObjectFilterProcPtr once for each file/directory
165 copied
166
167 The maxLevels parameter is only used when the object is a directory,
168 ignored otherwise.
169 It lets you control how deep the recursion goes.
170 If maxLevels is 1, FSCopyObject only scans the specified directory;
171 if maxLevels is 2, FSCopyObject scans the specified directory and
172 one subdirectory below the specified directory; etc. Set maxLevels to
173 zero to scan all levels.
174
175 The yourDataPtr parameter can point to whatever data structure you might
176 want to access from within your CopyObjectFilterProcPtr.
177
178 source --> The FSRef to the object you want to copy
179 destDir --> The FSRef to the directory you wish to copy source to
180 maxLevels --> Maximum number of directory levels to scan or
181 zero to scan all directory levels, ignored if the
182 object is a file
183 whichInfo --> The fields of the FSCatalogInfo you wish passed
184 to you in your CopyObjectFilterProc
185 wantFSSpec --> Set to true if you want the FSSpec to each
186 object passed to your CopyObjectFilterProc.
187 wantName --> Set to true if you want the name of each
188 object passed to your CopyObjectFilterProc.
189 iterateFilter --> A pointer to the CopyObjectFilterProc you
190 want called once for each object found
191 by FSCopyObject.
192 yourDataPtr --> An optional pointer to whatever data structure you
193 might want to access from within the
194 CopyObjectFilterProc.
195*/
196
197OSErr FSCopyObject( const FSRef *source,
198 const FSRef *destDir,
199 UniCharCount nameLength,
200 const UniChar *copyName, // can be NULL (no rename during copy)
201 ItemCount maxLevels,
202 FSCatalogInfoBitmap whichInfo,
203 Boolean wantFSSpec,
204 Boolean wantName,
205 CopyObjectFilterProcPtr filterProcPtr, // can be NULL
206 void *yourDataPtr, // can be NULL
207 FSRef *newObject); // can be NULL
208
209/*****************************************************************************/
210
211#pragma mark FSDeleteObjects
212
213/*
214 The FSDeleteObjects function takes an FSRef to a file or directory
215 and attempts to delete it. If the object is a directory, all files
216 and subdirectories in the specified directory are deleted. If a
217 locked file or directory is encountered, it is unlocked and then
218 deleted. After deleting the directory's contents, the directory
219 is deleted. If any unexpected errors are encountered,
220 FSDeleteContainer quits and returns to the caller.
221
222 source --> FSRef to an object (can be file or directory).
223
224 __________
225*/
226
227OSErr FSDeleteObjects( const FSRef *source );
228
229#ifdef __cplusplus
230}
231#endif
232
233#endif
Note: See TracBrowser for help on using the repository browser.

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