xref: /aoo41x/main/tools/inc/tools/fsys.hxx (revision 8b851043)
1*8b851043SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*8b851043SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*8b851043SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*8b851043SAndrew Rist  * distributed with this work for additional information
6*8b851043SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*8b851043SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*8b851043SAndrew Rist  * "License"); you may not use this file except in compliance
9*8b851043SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*8b851043SAndrew Rist  *
11*8b851043SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*8b851043SAndrew Rist  *
13*8b851043SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*8b851043SAndrew Rist  * software distributed under the License is distributed on an
15*8b851043SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*8b851043SAndrew Rist  * KIND, either express or implied.  See the License for the
17*8b851043SAndrew Rist  * specific language governing permissions and limitations
18*8b851043SAndrew Rist  * under the License.
19*8b851043SAndrew Rist  *
20*8b851043SAndrew Rist  *************************************************************/
21*8b851043SAndrew Rist 
22*8b851043SAndrew Rist 
23cdf0e10cSrcweir #ifndef _FSYS_HXX
24cdf0e10cSrcweir #define _FSYS_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <tools/solar.h>
27cdf0e10cSrcweir #include <tools/datetime.hxx>
28cdf0e10cSrcweir #include <tools/string.hxx>
29cdf0e10cSrcweir #include <tools/link.hxx>
30cdf0e10cSrcweir #include <tools/wldcrd.hxx>
31cdf0e10cSrcweir #ifndef __ERRCODE_HXX
32cdf0e10cSrcweir #include <tools/errcode.hxx>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include "tools/toolsdllapi.h"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <cstdarg>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #define FEAT_FSYS_DOUBLESPEED
39cdf0e10cSrcweir 
40cdf0e10cSrcweir // --------------
41cdf0e10cSrcweir // - FSys-Types -
42cdf0e10cSrcweir // --------------
43cdf0e10cSrcweir 
44cdf0e10cSrcweir class DirEntry;
45cdf0e10cSrcweir class DirEntryList;
46cdf0e10cSrcweir class FSysSortList;
47cdf0e10cSrcweir class FileStatList;
48cdf0e10cSrcweir struct FileCopier_Impl;
49cdf0e10cSrcweir class SvFileStream;
50cdf0e10cSrcweir class BigInt;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #define FSYS_BUFSIZE				1024
53cdf0e10cSrcweir #define FSYS_SHORTNAME_DELIMITER	'@'
54cdf0e10cSrcweir 
55cdf0e10cSrcweir // FSysAccess
56cdf0e10cSrcweir typedef int FSysAccess;
57cdf0e10cSrcweir #define FSYS_ACCESS_FORCED			1
58cdf0e10cSrcweir #define FSYS_ACCESS_FLOPPY			FSYS_ACCESS_FORCED
59cdf0e10cSrcweir #define FSYS_ACCESS_CACHED			2
60cdf0e10cSrcweir 
61cdf0e10cSrcweir // DirEntryKind
62cdf0e10cSrcweir typedef int DirEntryKind;
63cdf0e10cSrcweir #define FSYS_KIND_NONE				((DirEntryKind) 	0)
64cdf0e10cSrcweir #define FSYS_KIND_UNKNOWN			FSYS_KIND_NONE
65cdf0e10cSrcweir #define FSYS_KIND_FILE				((DirEntryKind) 	1)
66cdf0e10cSrcweir #define FSYS_KIND_DIR				((DirEntryKind) 	2)
67cdf0e10cSrcweir #define FSYS_KIND_DEV				((DirEntryKind) 	4)
68cdf0e10cSrcweir #define FSYS_KIND_BLOCK 			((DirEntryKind) 	8)
69cdf0e10cSrcweir #define FSYS_KIND_CHAR				((DirEntryKind)    16)
70cdf0e10cSrcweir #define FSYS_KIND_WILD				((DirEntryKind)    32)
71cdf0e10cSrcweir #define FSYS_KIND_BLOCK_REMOTE		((DirEntryKind)    64)	//TPF: fuer RFS
72cdf0e10cSrcweir #define FSYS_KIND_REMOVEABLE		((DirEntryKind)   128)
73cdf0e10cSrcweir #define FSYS_KIND_FIXED 			((DirEntryKind)   256)
74cdf0e10cSrcweir #define FSYS_KIND_REMOTE			((DirEntryKind)   512)
75cdf0e10cSrcweir #define FSYS_KIND_RAM				((DirEntryKind)  1024)
76cdf0e10cSrcweir #define FSYS_KIND_CDROM 			((DirEntryKind)  2048)
77cdf0e10cSrcweir #define FSYS_KIND_ALL				((DirEntryKind)  4095)
78cdf0e10cSrcweir #define FSYS_KIND_VISIBLE			((DirEntryKind)  4096)
79cdf0e10cSrcweir 
80cdf0e10cSrcweir // FSysSort
81cdf0e10cSrcweir typedef int FSysSort;
82cdf0e10cSrcweir #define FSYS_SORT_NONE				((FSysSort)   0)
83cdf0e10cSrcweir #define FSYS_SORT_SIZE				((FSysSort)   1)
84cdf0e10cSrcweir #define FSYS_SORT_CREATED			((FSysSort)   2)
85cdf0e10cSrcweir #define FSYS_SORT_MODIFYED			((FSysSort)   4)
86cdf0e10cSrcweir #define FSYS_SORT_ACCESSED			((FSysSort)   8)
87cdf0e10cSrcweir #define FSYS_SORT_ASCENDING 		((FSysSort)  16)
88cdf0e10cSrcweir #define FSYS_SORT_DESCENDING		((FSysSort)  32)
89cdf0e10cSrcweir #define FSYS_SORT_EXT				((FSysSort)  64)
90cdf0e10cSrcweir #define FSYS_SORT_NAME				((FSysSort) 128)
91cdf0e10cSrcweir #define FSYS_SORT_KIND				((FSysSort) 256)
92cdf0e10cSrcweir #define FSYS_SORT_CREATOR			((FSysSort) 512)
93cdf0e10cSrcweir #define FSYS_SORT_END				((FSysSort)1024)
94cdf0e10cSrcweir 
95cdf0e10cSrcweir // DirEntryFlag
96cdf0e10cSrcweir enum DirEntryFlag
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	FSYS_FLAG_NORMAL,
99cdf0e10cSrcweir 	FSYS_FLAG_VOLUME,					   // Dir( FSYS_FLAG_VOLUME ) und GetDevice()
100cdf0e10cSrcweir 	FSYS_FLAG_ABSROOT,					   // z.B. "a:\" oder "\"
101cdf0e10cSrcweir 	FSYS_FLAG_RELROOT,					   // z.B. "a:", "a:." oder "."
102cdf0e10cSrcweir 	FSYS_FLAG_CURRENT = FSYS_FLAG_RELROOT, // Synonym fuer FSYS_FLAG_RELROOT
103cdf0e10cSrcweir 	FSYS_FLAG_PARENT,					   // z.B. ".."
104cdf0e10cSrcweir 	FSYS_FLAG_INVALID
105cdf0e10cSrcweir };
106cdf0e10cSrcweir 
107cdf0e10cSrcweir // FSysPathStyle
108cdf0e10cSrcweir enum FSysPathStyle
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	FSYS_STYLE_HOST,
111cdf0e10cSrcweir 	FSYS_STYLE_FAT,
112cdf0e10cSrcweir 	FSYS_STYLE_MSDOS = FSYS_STYLE_FAT,
113cdf0e10cSrcweir 	FSYS_STYLE_VFAT,
114cdf0e10cSrcweir 	FSYS_STYLE_WIN95 = FSYS_STYLE_VFAT,
115cdf0e10cSrcweir 	FSYS_STYLE_HPFS,
116cdf0e10cSrcweir 	FSYS_STYLE_OS2 = FSYS_STYLE_HPFS,
117cdf0e10cSrcweir 	FSYS_STYLE_NTFS,
118cdf0e10cSrcweir 	FSYS_STYLE_NWFS,
119cdf0e10cSrcweir 	FSYS_STYLE_SYSV,
120cdf0e10cSrcweir 	FSYS_STYLE_BSD,
121cdf0e10cSrcweir 	FSYS_STYLE_UNX = FSYS_STYLE_BSD,
122cdf0e10cSrcweir 	FSYS_STYLE_MAC,
123cdf0e10cSrcweir 	FSYS_STYLE_DETECT,
124cdf0e10cSrcweir 	FSYS_STYLE_UNKNOWN,
125cdf0e10cSrcweir 	FSYS_STYLE_URL
126cdf0e10cSrcweir };
127cdf0e10cSrcweir 
128cdf0e10cSrcweir // FSysAction
129cdf0e10cSrcweir typedef int FSysAction;
130cdf0e10cSrcweir #define FSYS_ACTION_COPYFILE		0x01	// not only create hardlink
131cdf0e10cSrcweir #define FSYS_ACTION_RECURSIVE		0x02	// deep through dircetory structure
132cdf0e10cSrcweir #define FSYS_ACTION_USERECYCLEBIN	0x04	// move to recycle bin
133cdf0e10cSrcweir #define FSYS_ACTION_MOVE			0x08	// delete after copy (=> move)
134cdf0e10cSrcweir #define FSYS_ACTION_CONTINUE		0x10	// continue on error
135cdf0e10cSrcweir #define FSYS_ACTION_KEEP_EXISTING	0x20	// do not overwrite objects in
136cdf0e10cSrcweir 											// target folder in case of name
137cdf0e10cSrcweir 											// clashes
138cdf0e10cSrcweir #define FSYS_ACTION_STANDARD		0
139cdf0e10cSrcweir 
140cdf0e10cSrcweir // Fuer RFS
141cdf0e10cSrcweir #define RFS_IDENTIFIER	"-rfs-"
142cdf0e10cSrcweir #define RFS_LOWER		"-rfs-"
143cdf0e10cSrcweir #define RFS_UPPER		"-RFS-"
144cdf0e10cSrcweir 
145cdf0e10cSrcweir typedef sal_uIntPtr FSysError;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir // FSysExact
148cdf0e10cSrcweir enum FSysExact
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	FSYS_NOTEXACT,
151cdf0e10cSrcweir 	FSYS_EXACT
152cdf0e10cSrcweir };
153cdf0e10cSrcweir 
154cdf0e10cSrcweir // ------------
155cdf0e10cSrcweir // - Char-Set -
156cdf0e10cSrcweir // ------------
157cdf0e10cSrcweir 
158cdf0e10cSrcweir // Was different for WIN, no longer needed...
159cdf0e10cSrcweir #define GUI2FSYS(s) s
160cdf0e10cSrcweir #define FSYS2GUI(s) s
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 
163cdf0e10cSrcweir // ------------
164cdf0e10cSrcweir // - FileStat -
165cdf0e10cSrcweir // ------------
166cdf0e10cSrcweir 
167cdf0e10cSrcweir struct dirent;
168cdf0e10cSrcweir class TOOLS_DLLPUBLIC FileStat
169cdf0e10cSrcweir {
170cdf0e10cSrcweir 	friend class	CORmFSys;
171cdf0e10cSrcweir 	friend class	Dir;
172cdf0e10cSrcweir 	friend struct	DirReader_Impl;
173cdf0e10cSrcweir 	friend void 	ImpInitFileStat( FileStat&, dirent* );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	sal_uIntPtr			nError;
176cdf0e10cSrcweir 	DirEntryKind	nKindFlags;
177cdf0e10cSrcweir 	sal_uIntPtr			nSize;
178cdf0e10cSrcweir 	String			aCreator;
179cdf0e10cSrcweir 	String			aType;
180cdf0e10cSrcweir 	Date			aDateCreated;
181cdf0e10cSrcweir 	Time			aTimeCreated;
182cdf0e10cSrcweir 	Date			aDateModified;
183cdf0e10cSrcweir 	Time			aTimeModified;
184cdf0e10cSrcweir 	Date			aDateAccessed;
185cdf0e10cSrcweir 	Time			aTimeAccessed;
186cdf0e10cSrcweir private:
187cdf0e10cSrcweir 	TOOLS_DLLPRIVATE void			ImpInit( void* );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir protected:
190cdf0e10cSrcweir 					// Implementation
191cdf0e10cSrcweir 					FileStat( const void *pInfo,	  // CInfoPBRec
192cdf0e10cSrcweir 							  const void *pVolInfo ); // ParamBlockRec
193cdf0e10cSrcweir 
194cdf0e10cSrcweir public:
195cdf0e10cSrcweir 					FileStat();
196cdf0e10cSrcweir 					FileStat( const DirEntry& rDirEntry,
197cdf0e10cSrcweir 							  FSysAccess nAccess = FSYS_ACCESS_FLOPPY );
198cdf0e10cSrcweir 	sal_Bool			Update( const DirEntry& rDirEntry,
199cdf0e10cSrcweir 							  sal_Bool bForceAccess = sal_True );
200cdf0e10cSrcweir 
GetError() const201cdf0e10cSrcweir 	sal_uIntPtr			GetError() const { return ERRCODE_TOERROR(nError); }
GetErrorCode() const202cdf0e10cSrcweir 	sal_uIntPtr			GetErrorCode() const { return nError; }
203cdf0e10cSrcweir 
GetSize() const204cdf0e10cSrcweir 	sal_uIntPtr			GetSize() const { return nSize; }
205cdf0e10cSrcweir 
GetKind() const206cdf0e10cSrcweir 	DirEntryKind	GetKind() const { return nKindFlags; }
207cdf0e10cSrcweir 	sal_Bool			IsKind( DirEntryKind nKind ) const;
208cdf0e10cSrcweir 
GetType() const209cdf0e10cSrcweir 	String			GetType() const { return aType; }
GetCreator() const210cdf0e10cSrcweir 	String			GetCreator() const { return aCreator; }
211cdf0e10cSrcweir 
DateCreated() const212cdf0e10cSrcweir 	Date			DateCreated() const  { return aDateCreated;  }
TimeCreated() const213cdf0e10cSrcweir 	Time			TimeCreated() const  { return aTimeCreated;  }
DateModified() const214cdf0e10cSrcweir 	Date			DateModified() const { return aDateModified; }
TimeModified() const215cdf0e10cSrcweir 	Time			TimeModified() const { return aTimeModified; }
DateAccessed() const216cdf0e10cSrcweir 	Date			DateAccessed() const { return aDateAccessed; }
TimeAccessed() const217cdf0e10cSrcweir 	Time			TimeAccessed() const { return aTimeAccessed; }
218cdf0e10cSrcweir 	sal_Bool			IsYounger( const FileStat& rIsOlder ) const;
219cdf0e10cSrcweir 
220cdf0e10cSrcweir #define TF_FSYS_READONLY_FLAG
221cdf0e10cSrcweir 	static sal_uIntPtr	SetReadOnlyFlag( const DirEntry &rEntry, sal_Bool bRO = sal_True );
222cdf0e10cSrcweir 	static sal_Bool 	GetReadOnlyFlag( const DirEntry &rEntry );
223cdf0e10cSrcweir 	static sal_Bool 	HasReadOnlyFlag();
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	static ErrCode	QueryDiskSpace( const String &rPath,
226cdf0e10cSrcweir 									BigInt &rFreeBytes, BigInt &rTotalBytes );
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	static void 	SetDateTime( const String& rFileName,
229cdf0e10cSrcweir 								 const DateTime& rNewDateTime );
230cdf0e10cSrcweir };
231cdf0e10cSrcweir 
232cdf0e10cSrcweir // ------------
233cdf0e10cSrcweir // - DirEntry -
234cdf0e10cSrcweir // ------------
235cdf0e10cSrcweir 
236cdf0e10cSrcweir class DirEntryStack;
237cdf0e10cSrcweir 
238cdf0e10cSrcweir const char* ImpCheckDirEntry( const void* p );
239cdf0e10cSrcweir 
240cdf0e10cSrcweir class TOOLS_DLLPUBLIC DirEntry
241cdf0e10cSrcweir {
242cdf0e10cSrcweir friend struct DirReader_Impl;
243cdf0e10cSrcweir friend class FileCopier;
244cdf0e10cSrcweir 
245cdf0e10cSrcweir #ifdef FEAT_FSYS_DOUBLESPEED
246cdf0e10cSrcweir 	FileStat*			pStat;		// optional
247cdf0e10cSrcweir #endif
248cdf0e10cSrcweir 	ByteString			aName;
249cdf0e10cSrcweir 	DirEntry*			pParent;
250cdf0e10cSrcweir 	sal_uIntPtr				nError;
251cdf0e10cSrcweir 	DirEntryFlag		eFlag;
252cdf0e10cSrcweir 
253cdf0e10cSrcweir private:
254cdf0e10cSrcweir 	TOOLS_DLLPRIVATE 			DirEntry( const ByteString& rInitName,
255cdf0e10cSrcweir 								  DirEntryFlag aDirFlag,
256cdf0e10cSrcweir 								  FSysPathStyle eStyle );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 	friend class Dir;
261cdf0e10cSrcweir 	friend class FileStat;
262cdf0e10cSrcweir 	friend const char* ImpCheckDirEntry( const void* p );
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	TOOLS_DLLPRIVATE FSysError			ImpParseName( const ByteString& rIntiName,
265cdf0e10cSrcweir 									  FSysPathStyle eParser );
266cdf0e10cSrcweir 	TOOLS_DLLPRIVATE FSysError			ImpParseOs2Name( const ByteString& rPfad,
267cdf0e10cSrcweir 										 FSysPathStyle eStyle );
268cdf0e10cSrcweir 	TOOLS_DLLPRIVATE FSysError			ImpParseUnixName( const ByteString& rPfad,
269cdf0e10cSrcweir 										  FSysPathStyle eStyle );
270cdf0e10cSrcweir 	TOOLS_DLLPRIVATE sal_uInt16				ImpTryUrl( DirEntryStack& rStack, const String& rPfad, FSysPathStyle eStyle );
271cdf0e10cSrcweir 	TOOLS_DLLPRIVATE const DirEntry* 	ImpGetTopPtr() const;
272cdf0e10cSrcweir 	TOOLS_DLLPRIVATE DirEntry*			ImpGetTopPtr();
273cdf0e10cSrcweir 	TOOLS_DLLPRIVATE DirEntry*			ImpGetPreTopPtr();
274cdf0e10cSrcweir 	TOOLS_DLLPRIVATE sal_Bool				ImpToRel( String aStart );
275cdf0e10cSrcweir 
276cdf0e10cSrcweir protected:
277cdf0e10cSrcweir 	void				ImpTrim( FSysPathStyle eStyle );
278cdf0e10cSrcweir 	const ByteString&	ImpTheName() const;
ImpTheFlag() const279cdf0e10cSrcweir 	DirEntryFlag		ImpTheFlag() const { return eFlag; };
280cdf0e10cSrcweir 	DirEntry*			ImpChangeParent( DirEntry* pNewParent, sal_Bool bNormalize = sal_True );
ImpGetParent()281cdf0e10cSrcweir 	DirEntry*			ImpGetParent() { return pParent; }
282cdf0e10cSrcweir #ifdef FEAT_FSYS_DOUBLESPEED
ImpGetStat() const283cdf0e10cSrcweir 	FileStat*			ImpGetStat() const { return pStat; }
ImpSetStat(FileStat * p)284cdf0e10cSrcweir 	void				ImpSetStat( FileStat *p ) { pStat = p; }
285cdf0e10cSrcweir #endif
286cdf0e10cSrcweir 
287cdf0e10cSrcweir //#endif
288cdf0e10cSrcweir 
289cdf0e10cSrcweir protected:
SetError(sal_uIntPtr nErr)290cdf0e10cSrcweir 	void				SetError( sal_uIntPtr nErr ) { nError = nErr; }
GetParent()291cdf0e10cSrcweir 	DirEntry*			GetParent() { return pParent; }
292cdf0e10cSrcweir public:
293cdf0e10cSrcweir 						DirEntry( DirEntryFlag aDirFlag = FSYS_FLAG_CURRENT );
294cdf0e10cSrcweir 						DirEntry( const DirEntry& rEntry );
295cdf0e10cSrcweir 						DirEntry( const ByteString& rInitName,
296cdf0e10cSrcweir 								   FSysPathStyle eParser = FSYS_STYLE_HOST );
297cdf0e10cSrcweir 						DirEntry( const String& rInitName,
298cdf0e10cSrcweir 								   FSysPathStyle eParser = FSYS_STYLE_HOST );
299cdf0e10cSrcweir 						~DirEntry();
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 	sal_Bool				IsLongNameOnFAT() const;
302cdf0e10cSrcweir 	sal_Bool				IsCaseSensitive (FSysPathStyle eFormatter = FSYS_STYLE_HOST) const;
303cdf0e10cSrcweir 
GetError() const304cdf0e10cSrcweir 	sal_uIntPtr				GetError() const { return nError; }
305cdf0e10cSrcweir 	sal_Bool				IsValid() const;
GetFlag() const306cdf0e10cSrcweir 	DirEntryFlag		GetFlag() const { return eFlag; };
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 	void				SetExtension( const String& rExt, char cSep = '.' );
309cdf0e10cSrcweir 	String				GetExtension( char cSep = '.' ) const;
310cdf0e10cSrcweir 	String				CutExtension( char cSep = '.' );
311cdf0e10cSrcweir 	void				SetName( const String& rName, FSysPathStyle eFormatter = FSYS_STYLE_HOST );
GetNameDirect() const312cdf0e10cSrcweir 	inline const String GetNameDirect() const { return String(aName, osl_getThreadTextEncoding()); }
313cdf0e10cSrcweir 	String				GetName( FSysPathStyle eFormatter = FSYS_STYLE_HOST ) const;
314cdf0e10cSrcweir 	String				CutName( FSysPathStyle eFormatter = FSYS_STYLE_HOST );
315cdf0e10cSrcweir 	void				SetBase( const String& rBase, char cSep = '.' );
316cdf0e10cSrcweir 	String				GetBase(char cSep = '.' ) const;
317cdf0e10cSrcweir 	DirEntry			GetPath() const;
318cdf0e10cSrcweir 	DirEntry			GetDevice() const;
319cdf0e10cSrcweir 	String				GetVolume() const;
320cdf0e10cSrcweir 	String				GetFull( FSysPathStyle eFormatter = FSYS_STYLE_HOST,
321cdf0e10cSrcweir 								 sal_Bool bWithDelimiter = sal_False,
322cdf0e10cSrcweir 								 sal_uInt16 nMaxChars = STRING_MAXLEN ) const;
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	DirEntry			TempName( DirEntryKind = FSYS_KIND_NONE ) const;
325cdf0e10cSrcweir 	static const DirEntry& SetTempNameBase( const String &rBaseName );
326cdf0e10cSrcweir 	sal_Bool				MakeShortName( const String& rLongName,
327cdf0e10cSrcweir 									   DirEntryKind eCreateKind = FSYS_KIND_NONE,
328cdf0e10cSrcweir 									   sal_Bool bUseTilde = sal_True,
329cdf0e10cSrcweir 									   FSysPathStyle eStyle = FSYS_STYLE_DETECT );
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 	bool				IsAbs() const;
332cdf0e10cSrcweir 	sal_Bool				ToAbs();
333cdf0e10cSrcweir 	sal_Bool				Find( const String& rPfad, char cDelim = 0 );
334cdf0e10cSrcweir 	sal_Bool				ToRel();
335cdf0e10cSrcweir 	sal_Bool				ToRel( const DirEntry& rRefDir );
336cdf0e10cSrcweir 	sal_uInt16				CutRelParents();
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 	sal_Bool				SetCWD( sal_Bool bSloppy = sal_False ) const;
339cdf0e10cSrcweir 	sal_Bool				MakeDir( sal_Bool bSloppy = sal_False ) const;
340cdf0e10cSrcweir 	sal_Bool				Exists( FSysAccess nAccess = FSYS_ACCESS_FLOPPY ) const;
341cdf0e10cSrcweir 	sal_Bool				First();
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	sal_uInt16				Level() const;
344cdf0e10cSrcweir 	const DirEntry& 	operator []( sal_uInt16 nParentLevel ) const;
345cdf0e10cSrcweir 	sal_Bool				Contains( const DirEntry &rSubEntry ) const;
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 	FSysError			CopyTo( const DirEntry& rDestDir,
348cdf0e10cSrcweir 								FSysAction nActions = FSYS_ACTION_STANDARD ) const;
349cdf0e10cSrcweir 	FSysError			MoveTo( const DirEntry& rDestDir ) const;
350cdf0e10cSrcweir 	FSysError			Kill( FSysAction nActions = FSYS_ACTION_STANDARD ) const;
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 	DirEntry&			operator =( const DirEntry& rOrigDir );
353cdf0e10cSrcweir 	DirEntry			operator +( const DirEntry& rSubDir ) const;
354cdf0e10cSrcweir 	DirEntry&			operator +=( const DirEntry& rSubDir );
355cdf0e10cSrcweir 	sal_Bool				operator ==( const DirEntry& rAnotherDir ) const;
operator !=(const DirEntry & rAnotherDir) const356cdf0e10cSrcweir 	sal_Bool				operator !=( const DirEntry& rAnotherDir ) const
357cdf0e10cSrcweir 							{ return !(DirEntry::operator==( rAnotherDir )); }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	StringCompare		NameCompare( const DirEntry &rWith ) const;
NameCompareDirect(const DirEntry & rWith) const360cdf0e10cSrcweir 	inline StringCompare NameCompareDirect( const DirEntry &rWith ) const
361cdf0e10cSrcweir 						{
362cdf0e10cSrcweir #ifdef UNX
363cdf0e10cSrcweir 							return rWith.aName.CompareTo( aName );
364cdf0e10cSrcweir #else
365cdf0e10cSrcweir 							return rWith.aName.CompareIgnoreCaseToAscii( aName );
366cdf0e10cSrcweir #endif
367cdf0e10cSrcweir 						}
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 	static String		GetAccessDelimiter( FSysPathStyle eFormatter = FSYS_STYLE_HOST );
370cdf0e10cSrcweir 	static String		GetSearchDelimiter( FSysPathStyle eFormatter = FSYS_STYLE_HOST );
371cdf0e10cSrcweir 	static sal_uInt16		GetMaxNameLen( FSysPathStyle eFormatter = FSYS_STYLE_HOST );
372cdf0e10cSrcweir 	static FSysPathStyle GetPathStyle( const String &rDevice );
373cdf0e10cSrcweir 	static String		ConvertNameToSystem( const String & rName );
374cdf0e10cSrcweir 	static String		ConvertSystemToName( const String & rName );
375cdf0e10cSrcweir 	static sal_Bool 		IsRFSAvailable();
376cdf0e10cSrcweir };
377cdf0e10cSrcweir 
378cdf0e10cSrcweir // --------------
379cdf0e10cSrcweir // - FileCopier -
380cdf0e10cSrcweir // --------------
381cdf0e10cSrcweir 
382cdf0e10cSrcweir class TOOLS_DLLPUBLIC FileCopier
383cdf0e10cSrcweir {
384cdf0e10cSrcweir 	DirEntry			aSource;
385cdf0e10cSrcweir 	DirEntry			aTarget;
386cdf0e10cSrcweir 	sal_uIntPtr				nBytesTotal;
387cdf0e10cSrcweir 	sal_uIntPtr				nBytesCopied;
388cdf0e10cSrcweir 	Link				aProgressLink;
389cdf0e10cSrcweir 	sal_uInt16				nBlockSize;
390cdf0e10cSrcweir 	FileCopier_Impl*	pImp;
391cdf0e10cSrcweir 
392cdf0e10cSrcweir private:
393cdf0e10cSrcweir 	TOOLS_DLLPRIVATE FSysError			DoCopy_Impl(
394cdf0e10cSrcweir         const DirEntry &rSource, const DirEntry &rTarget );
395cdf0e10cSrcweir 
396cdf0e10cSrcweir protected:
397cdf0e10cSrcweir 	virtual sal_Bool		Progress();
398cdf0e10cSrcweir 	virtual ErrCode 	Error( ErrCode eErr,
399cdf0e10cSrcweir 							   const DirEntry *pSource, const DirEntry *pTarget );
400cdf0e10cSrcweir 
401cdf0e10cSrcweir public:
402cdf0e10cSrcweir 						FileCopier();
403cdf0e10cSrcweir 						FileCopier( const DirEntry &rSource,
404cdf0e10cSrcweir 									const DirEntry &rTarget );
405cdf0e10cSrcweir 						FileCopier( const FileCopier &rCopier );
406cdf0e10cSrcweir 						virtual ~FileCopier();
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	FileCopier& 		operator = ( const FileCopier &rCopier );
409cdf0e10cSrcweir 
SetBlockSize(sal_uInt16 nBytes)410cdf0e10cSrcweir 	void				SetBlockSize( sal_uInt16 nBytes ) { nBlockSize = nBytes; }
GetBlockSize() const411cdf0e10cSrcweir 	sal_uInt16				GetBlockSize() const { return nBlockSize; }
412cdf0e10cSrcweir 
GetBytesTotal() const413cdf0e10cSrcweir 	sal_uIntPtr				GetBytesTotal() const { return nBytesTotal; }
GetBytesCopied() const414cdf0e10cSrcweir 	sal_uIntPtr				GetBytesCopied() const { return nBytesCopied; }
415cdf0e10cSrcweir 
SetSource(const DirEntry & rSource)416cdf0e10cSrcweir 	void				SetSource( const DirEntry &rSource ) { aSource = rSource; }
SetTarget(const DirEntry & rTarget)417cdf0e10cSrcweir 	void				SetTarget( const DirEntry &rTarget ) { aTarget = rTarget; }
GetSource() const418cdf0e10cSrcweir 	const DirEntry& 	GetSource() const { return aSource; }
GetTarget() const419cdf0e10cSrcweir 	const DirEntry& 	GetTarget() const { return aTarget; }
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 	FSysError			Execute( FSysAction nActions = FSYS_ACTION_STANDARD );
422cdf0e10cSrcweir 	FSysError			ExecuteExact( FSysAction nActions = FSYS_ACTION_STANDARD,
423cdf0e10cSrcweir 																 FSysExact	eExact = FSYS_NOTEXACT);
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 	const DirEntry* 	GetErrorSource() const;
426cdf0e10cSrcweir 	const DirEntry* 	GetErrorTarget() const;
427cdf0e10cSrcweir 	ErrCode 			GetError() const;
428cdf0e10cSrcweir 
SetProgressHdl(const Link & rLink)429cdf0e10cSrcweir 	void				SetProgressHdl( const Link& rLink ) { aProgressLink = rLink; }
GetProgressHdl() const430cdf0e10cSrcweir 	const Link& 		GetProgressHdl() const { return aProgressLink; }
431cdf0e10cSrcweir 	void				SetErrorHdl( const Link& rLink );
432cdf0e10cSrcweir 	const Link& 		GetErrorHdl() const;
433cdf0e10cSrcweir };
434cdf0e10cSrcweir 
435cdf0e10cSrcweir // -------
436cdf0e10cSrcweir // - Dir -
437cdf0e10cSrcweir // -------
438cdf0e10cSrcweir 
439cdf0e10cSrcweir struct DirReader_Impl;
440cdf0e10cSrcweir class TOOLS_DLLPUBLIC Dir : public DirEntry
441cdf0e10cSrcweir {
442cdf0e10cSrcweir friend struct DirReader_Impl;
443cdf0e10cSrcweir friend class CORmFSys;
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 	DirReader_Impl* pReader;		// systemabhaengig
446cdf0e10cSrcweir 	DirEntryList*	pLst;
447cdf0e10cSrcweir 	FSysSortList*	pSortLst;		// NULL, wenn kein Sort gefordert
448cdf0e10cSrcweir 	FileStatList*	pStatLst;		// NULL, wenn keine Stat's benoetigt
449cdf0e10cSrcweir 	WildCard		aNameMask;
450cdf0e10cSrcweir     DirEntryKind eAttrMask;
451cdf0e10cSrcweir 
452cdf0e10cSrcweir private:
453cdf0e10cSrcweir 	TOOLS_DLLPRIVATE			Dir( const Dir& );			// not allowed
454cdf0e10cSrcweir 	TOOLS_DLLPRIVATE Dir&			operator=( const Dir& );	// not allowed
455cdf0e10cSrcweir 
456cdf0e10cSrcweir #ifdef _DIR_CXX
457cdf0e10cSrcweir 	TOOLS_DLLPRIVATE FSysError		ImpSetSort( std::va_list pArgs, FSysSort nSort );
458cdf0e10cSrcweir 	TOOLS_DLLPRIVATE void			Construct( DirEntryKind nKind = FSYS_KIND_DIR|FSYS_KIND_FILE );
459cdf0e10cSrcweir #endif
460cdf0e10cSrcweir 
461cdf0e10cSrcweir #ifndef _TOOLS_HXX
462cdf0e10cSrcweir protected:
463cdf0e10cSrcweir 	sal_Bool			ImpInsertPointReached( const DirEntry& rIsSmaller,
464cdf0e10cSrcweir 										   const FileStat& rNewStat,
465cdf0e10cSrcweir 										   sal_uIntPtr nCurPos,
466cdf0e10cSrcweir 										   sal_uIntPtr nSortIndex ) const;
467cdf0e10cSrcweir 	void			ImpSortedInsert( const DirEntry *pNewEntry,
468cdf0e10cSrcweir 									 const FileStat *pNewStat );
469cdf0e10cSrcweir #endif
470cdf0e10cSrcweir 
471cdf0e10cSrcweir public:
472cdf0e10cSrcweir 					Dir();
473cdf0e10cSrcweir 					Dir( const DirEntry& rDirEntry,
474cdf0e10cSrcweir 						 DirEntryKind nKind = FSYS_KIND_ALL );
475cdf0e10cSrcweir 					Dir( const DirEntry& rDirEntry,
476cdf0e10cSrcweir 						 DirEntryKind nKind,
477cdf0e10cSrcweir 						 FSysSort nSort, ... );
478cdf0e10cSrcweir 					~Dir();
479cdf0e10cSrcweir 
GetNameMask() const480cdf0e10cSrcweir 	const WildCard& GetNameMask() const { return aNameMask; }
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 	FSysError		SetSort( FSysSort nSort, ... );
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 	void			Reset();
485cdf0e10cSrcweir 	sal_uInt16			Scan( sal_uInt16 nCount = 5 );
486cdf0e10cSrcweir 	sal_uInt16			Count( sal_Bool bUpdated = sal_True ) const;
487cdf0e10cSrcweir 	sal_Bool			Update();
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 	Dir&			operator +=( const Dir& rDir );
490cdf0e10cSrcweir 	DirEntry&		operator []( sal_uInt16 nIndex ) const;
491cdf0e10cSrcweir };
492cdf0e10cSrcweir 
493cdf0e10cSrcweir // we don't need this stuff for bootstraping
494cdf0e10cSrcweir #ifndef BOOTSTRAP
495cdf0e10cSrcweir 
496cdf0e10cSrcweir //========================================================================
497cdf0e10cSrcweir 
498cdf0e10cSrcweir /** FSysRedirector is an abstract base class for a hook to redirect
499cdf0e10cSrcweir 	mirrored directory trees.
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 	<P>One instance of a subclass can be instanciated and registered
502cdf0e10cSrcweir 	using the method FSysRedirector::Register(FSysRedirector*).
503cdf0e10cSrcweir  */
504cdf0e10cSrcweir 
505cdf0e10cSrcweir class FSysRedirector
506cdf0e10cSrcweir {
507cdf0e10cSrcweir 	static FSysRedirector*	_pRedirector;
508cdf0e10cSrcweir 	static sal_Bool 			_bEnabled;
509cdf0e10cSrcweir 
510cdf0e10cSrcweir public:
511cdf0e10cSrcweir 	/** This method must called with the one and only instance of the
512cdf0e10cSrcweir 		subclass which implements the redirection.
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 		<P>It must be called with 0 when the instance is destroyed.
515cdf0e10cSrcweir 	 */
516cdf0e10cSrcweir 	static void 			Register( FSysRedirector *pRedirector );
517cdf0e10cSrcweir 
518cdf0e10cSrcweir 	//-----------------------------------------------------------------------
519cdf0e10cSrcweir 	/** This method returns the currently registererd instance of
520cdf0e10cSrcweir 		a subclass which implements the redirection.
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 		<P>If no redirector is registered, it returns 0.
523cdf0e10cSrcweir 	 */
524cdf0e10cSrcweir 	static FSysRedirector*	Redirector();
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 	//-----------------------------------------------------------------------
527cdf0e10cSrcweir 	/** This method is to be used to redirect a file system path.
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 		<P>It will not redirect while redirection is disabled.
530cdf0e10cSrcweir 
531cdf0e10cSrcweir 		<P>It may block while another thread is accessing the redirector
532cdf0e10cSrcweir 		or another thread has disabled redirections.
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 		@param String &rPath<BR>
535cdf0e10cSrcweir 				This inout-argument accepts a file:-URL even as a native
536cdf0e10cSrcweir 				file system path name to redirect in 'rPath'. It returns the
537cdf0e10cSrcweir 				redirected (modified) path too, which can be of both formats
538cdf0e10cSrcweir 				too.
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 		@return sal_Bool<BR>
541cdf0e10cSrcweir 				sal_True, if the path is redirected
542cdf0e10cSrcweir 				sal_False, if the path is not redirected (unchanged)
543cdf0e10cSrcweir 	 */
544cdf0e10cSrcweir 	static void 			DoRedirect( String &rPath );
545cdf0e10cSrcweir };
546cdf0e10cSrcweir 
547cdf0e10cSrcweir #endif // BOOTSTRP
548cdf0e10cSrcweir 
549cdf0e10cSrcweir //========================================================================
550cdf0e10cSrcweir 
551cdf0e10cSrcweir void FSysEnableSysErrorBox( sal_Bool bEnable );
552cdf0e10cSrcweir 
553cdf0e10cSrcweir //========================================================================
554cdf0e10cSrcweir 
555cdf0e10cSrcweir #if defined(DBG_UTIL)
556cdf0e10cSrcweir void FSysTest();
557cdf0e10cSrcweir #endif
558cdf0e10cSrcweir 
559cdf0e10cSrcweir #endif // #ifndef _FSYS_HXX
560cdf0e10cSrcweir 
561