aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/mac_updater/FSCopyObject.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/mac_updater/FSCopyObject.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/mac_updater/FSCopyObject.h285
1 files changed, 285 insertions, 0 deletions
diff --git a/linden/indra/mac_updater/FSCopyObject.h b/linden/indra/mac_updater/FSCopyObject.h
new file mode 100644
index 0000000..6cbbf94
--- /dev/null
+++ b/linden/indra/mac_updater/FSCopyObject.h
@@ -0,0 +1,285 @@
1/**
2 * @file FSCopyObject.h
3 * @brief Mac OSX updater program
4 *
5 * Copyright (c) 2004-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28/*
29 File: FSCopyObject.h
30
31 Contains: A Copy/Delete Files/Folders engine which uses the HFS+ API's
32
33 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
34 ("Apple") in consideration of your agreement to the following terms, and your
35 use, installation, modification or redistribution of this Apple software
36 constitutes acceptance of these terms. If you do not agree with these terms,
37 please do not use, install, modify or redistribute this Apple software.
38
39 In consideration of your agreement to abide by the following terms, and subject
40 to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
41 copyrights in this original Apple software (the "Apple Software"), to use,
42 reproduce, modify and redistribute the Apple Software, with or without
43 modifications, in source and/or binary forms; provided that if you redistribute
44 the Apple Software in its entirety and without modifications, you must retain
45 this notice and the following text and disclaimers in all such redistributions of
46 the Apple Software. Neither the name, trademarks, service marks or logos of
47 Apple Computer, Inc. may be used to endorse or promote products derived from the
48 Apple Software without specific prior written permission from Apple. Except as
49 expressly stated in this notice, no other rights or licenses, express or implied,
50 are granted by Apple herein, including but not limited to any patent rights that
51 may be infringed by your derivative works or by other works in which the Apple
52 Software may be incorporated.
53
54 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
55 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
56 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
57 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
58 COMBINATION WITH YOUR PRODUCTS.
59
60 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
61 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
62 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
64 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
65 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
66 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67
68 Copyright © 2002-2004 Apple Computer, Inc., All Rights Reserved
69*/
70
71
72#ifndef __FSCOPYOBJECT_H__
73#define __FSCOPYOBJECT_H__
74
75#ifdef __cplusplus
76extern "C" {
77#endif
78
79#if TARGET_API_MAC_OSX || defined( __APPLE_CC__ )
80#include <CoreServices/CoreServices.h>
81#endif
82
83#define DEBUG 1 /* set to zero if you don't want debug spew */
84
85#if DEBUG
86 #include <stdio.h>
87
88 #define QuoteExceptionString(x) #x
89
90 #define dwarning(s) do { printf s; fflush(stderr); } while( 0 )
91
92 #define mycheck_noerr( error ) \
93 do { \
94 if( (OSErr) error != noErr ) { \
95 dwarning((QuoteExceptionString(error) " != noErr in File: %s, Function: %s, Line: %d, Error: %d\n", \
96 __FILE__, __FUNCTION__, __LINE__, (OSErr) error)); \
97 } \
98 } while( false )
99
100 #define mycheck( assertion ) \
101 do { \
102 if( ! assertion ) { \
103 dwarning((QuoteExceptionString(assertion) " failed in File: %s, Function: %s, Line: %d\n", \
104 __FILE__, __FUNCTION__, __LINE__)); \
105 } \
106 } while( false )
107
108 #define myverify(assertion) mycheck(assertion)
109 #define myverify_noerr(assertion) mycheck_noerr( (assertion) )
110#else
111 #define dwarning(s)
112
113 #define mycheck(assertion)
114 #define mycheck_noerr(err)
115 #define myverify(assertion) do { (void) (assertion); } while (0)
116 #define myverify_noerr(assertion) myverify(assertion)
117#endif
118
119/*
120 This code takes some tricks/techniques from MoreFilesX (by Jim Luther) and
121 MPFileCopy (by Quinn), wraps them all up into an easy to use API, and adds a bunch of
122 features and bug fixes. It will run on Mac OS 9.1 through 9.2.x and 10.1.x
123 and up (Classic, Carbon and Mach-O)
124*/
125
126 /* Different options that FSCopyObject can take during a copy */
127typedef UInt32 DupeAction;
128enum {
129 kDupeActionStandard, /* will do the copy with no frills */
130 kDupeActionReplace, /* will delete the existing object and then copy over the new one */
131 kDupeActionRename /* will rename the new object if an object of the same name exists */
132};
133
134/*****************************************************************************/
135
136#pragma mark CopyObjectFilterProcPtr
137
138/*
139 This is the prototype for the CallCopyObjectFilterProc function which
140 is called once for each file and directory found by FSCopyObject.
141 The CallCopyObjectFilterProc can use the read-only data it receives for
142 whatever it wants.
143
144 The result of the CallCopyObjectFilterProc function indicates if
145 the copy should be stopped. To stop the copy, return an error; to continue
146 the copy, return noErr.
147
148 The yourDataPtr parameter can point to whatever data structure you might
149 want to access from within the CallCopyObjectFilterProc.
150
151 Note: If an error had occured during the copy of the current object
152 (currentOSErr != noErr) the FSRef etc might not be valid
153
154 containerChanged --> Set to true if the container's contents changed
155 during iteration.
156 currentLevel --> The current recursion level into the container.
157 1 = the container, 2 = the container's immediate
158 subdirectories, etc.
159 currentOSErr --> The current error code, shows the results of the
160 copy of the current object (ref)
161 catalogInfo --> The catalog information for the current object.
162 Only the fields requested by the whichInfo
163 parameter passed to FSIterateContainer are valid.
164 ref --> The FSRef to the current object.
165 spec --> The FSSpec to the current object if the wantFSSpec
166 parameter passed to FSCopyObject is true.
167 name --> The name of the current object if the wantName
168 parameter passed to FSCopyObject is true.
169 yourDataPtr --> An optional pointer to whatever data structure you
170 might want to access from within the
171 CallCopyObjectFilterProc.
172 result <-- To continue the copy, return noErr
173
174 __________
175
176 Also see: FSCopyObject
177*/
178
179typedef CALLBACK_API( OSErr , CopyObjectFilterProcPtr ) (
180 Boolean containerChanged,
181 ItemCount currentLevel,
182 OSErr currentOSErr,
183 const FSCatalogInfo *catalogInfo,
184 const FSRef *ref,
185 const FSSpec *spec,
186 const HFSUniStr255 *name,
187 void *yourDataPtr);
188
189
190/*****************************************************************************/
191
192#pragma mark CallCopyObjectFilterProc
193
194#define CallCopyObjectFilterProc(userRoutine, containerChanged, currentLevel, currentOSErr, catalogInfo, ref, spec, name, yourDataPtr) \
195 (*(userRoutine))((containerChanged), (currentLevel), (currentOSErr), (catalogInfo), (ref), (spec), (name), (yourDataPtr))
196
197/*****************************************************************************/
198
199#pragma mark FSCopyObject
200
201/*
202 The FSCopyObject function takes a source object (can be a file or directory)
203 and copies it (and its contents if it's a directory) to the new destination
204 directory.
205
206 It will call your CopyObjectFilterProcPtr once for each object copied
207
208 The maxLevels parameter is only used when the object is a directory,
209 ignored otherwise.
210 It lets you control how deep the recursion goes.
211 If maxLevels is 1, FSCopyObject only scans the specified directory;
212 if maxLevels is 2, FSCopyObject scans the specified directory and
213 one subdirectory below the specified directory; etc. Set maxLevels to
214 zero to scan all levels.
215
216 The yourDataPtr parameter can point to whatever data structure you might
217 want to access from within your CopyObjectFilterProcPtr.
218
219 source --> The FSRef to the object you want to copy
220 destDir --> The FSRef to the directory you wish to copy source to
221 maxLevels --> Maximum number of directory levels to scan or
222 zero to scan all directory levels, ignored if the
223 object is a file
224 whichInfo --> The fields of the FSCatalogInfo you wish passed
225 to you in your CopyObjectFilterProc
226 dupeAction --> The action to take if an object of the same name exists
227 in the destination
228 newName --> The name you want the new object to have. If you pass
229 in NULL, the source object name will be used.
230 wantFSSpec --> Set to true if you want the FSSpec to each
231 object passed to your CopyObjectFilterProc.
232 wantName --> Set to true if you want the name of each
233 object passed to your CopyObjectFilterProc.
234 filterProcPtr --> A pointer to the CopyObjectFilterProc you
235 want called once for each object found
236 by FSCopyObject.
237 yourDataPtr --> An optional pointer to whatever data structure you
238 might want to access from within the
239 CopyObjectFilterProc.
240 newObjectRef --> An optional pointer to an FSRef that, on return,
241 references the new object. If you don't want this
242 info returned, pass in NULL
243 newObjectSpec --> An optional pointer to an FSSPec that, on return,
244 references the new object. If you don't want this
245 info returned, pass in NULL
246*/
247
248OSErr FSCopyObject( const FSRef *source,
249 const FSRef *destDir,
250 ItemCount maxLevels,
251 FSCatalogInfoBitmap whichInfo,
252 DupeAction dupeAction,
253 const HFSUniStr255 *newName, /* can be NULL */
254 Boolean wantFSSpec,
255 Boolean wantName,
256 CopyObjectFilterProcPtr filterProcPtr, /* can be NULL */
257 void *yourDataPtr, /* can be NULL */
258 FSRef *newObjectRef, /* can be NULL */
259 FSSpec *newObjectSpec); /* can be NULL */
260
261/*****************************************************************************/
262
263#pragma mark FSDeleteObjects
264
265/*
266 The FSDeleteObjects function takes an FSRef to a file or directory
267 and attempts to delete it. If the object is a directory, all files
268 and subdirectories in the specified directory are deleted. If a
269 locked file or directory is encountered, it is unlocked and then
270 deleted. After deleting the directory's contents, the directory
271 is deleted. If any unexpected errors are encountered,
272 FSDeleteContainer quits and returns to the caller.
273
274 source --> FSRef to an object (can be file or directory).
275
276 __________
277*/
278
279OSErr FSDeleteObjects( const FSRef *source );
280
281#ifdef __cplusplus
282}
283#endif
284
285#endif