xref: /aoo41x/main/tools/source/fsys/comdep.hxx (revision 67e470da)
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 
24cdf0e10cSrcweir #ifndef _COMDEP_HXX
25cdf0e10cSrcweir #define _COMDEP_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools/fsys.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #define ACCESSDELIM(e)  ( (e == FSYS_STYLE_MAC) ? ":" : \
30cdf0e10cSrcweir 						( ( e == FSYS_STYLE_VFAT || e == FSYS_STYLE_HPFS || \
31cdf0e10cSrcweir 						    e == FSYS_STYLE_FAT ) || e == FSYS_STYLE_NTFS ) \
32cdf0e10cSrcweir 						  ? "\\" : "/" )
33cdf0e10cSrcweir #define ACCESSDELIM_C(e)(char)\
34cdf0e10cSrcweir                         ( (e == FSYS_STYLE_MAC) ? ':' : \
35cdf0e10cSrcweir 						( ( e == FSYS_STYLE_VFAT || e == FSYS_STYLE_HPFS || \
36cdf0e10cSrcweir 						    e == FSYS_STYLE_FAT ) || e == FSYS_STYLE_NTFS ) \
37cdf0e10cSrcweir 						  ? '\\' : '/' )
38cdf0e10cSrcweir #define SEARCHDELIM(e)  ( (e == FSYS_STYLE_SYSV || e == FSYS_STYLE_BSD) ? ":" \
39cdf0e10cSrcweir                         : ";" )
40cdf0e10cSrcweir #define SEARCHDELIM_C(e)(char)\
41cdf0e10cSrcweir                         ( (e == FSYS_STYLE_SYSV || e == FSYS_STYLE_BSD) ? ':' \
42cdf0e10cSrcweir                         : ';' )
43cdf0e10cSrcweir #define ACTPARENT(e)    ( (e == FSYS_STYLE_MAC) ? ":" : ".." )
44cdf0e10cSrcweir #define ACTCURRENT(e)   ( (e == FSYS_STYLE_MAC) ? "" : "." )
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #if defined UNX
47cdf0e10cSrcweir #include "unx.hxx"
48cdf0e10cSrcweir #elif defined WNT
49cdf0e10cSrcweir #include "wntmsc.hxx"
50cdf0e10cSrcweir #elif defined OS2
51cdf0e10cSrcweir #include "os2.hxx"
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //--------------------------------------------------------------------
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #ifndef LINUX
57cdf0e10cSrcweir DIR *opendir( const char* pPfad );
58cdf0e10cSrcweir dirent *readdir( DIR *pDir );
59cdf0e10cSrcweir int closedir( DIR *pDir );
60cdf0e10cSrcweir char *volumeid( const char* pPfad );
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //--------------------------------------------------------------------
64cdf0e10cSrcweir 
65cdf0e10cSrcweir struct DirReader_Impl
66cdf0e10cSrcweir {
67cdf0e10cSrcweir 	Dir*		pDir;
68cdf0e10cSrcweir     DIR*        pDosDir;
69cdf0e10cSrcweir     dirent*     pDosEntry;
70cdf0e10cSrcweir     DirEntry*   pParent;
71cdf0e10cSrcweir     String  	aPath;
72cdf0e10cSrcweir     ByteString  aBypass;
73cdf0e10cSrcweir     sal_Bool        bReady;
74cdf0e10cSrcweir 	sal_Bool		bInUse;
75cdf0e10cSrcweir 
DirReader_ImplDirReader_Impl76cdf0e10cSrcweir 				DirReader_Impl( Dir &rDir )
77cdf0e10cSrcweir 				:	pDir( &rDir ),
78cdf0e10cSrcweir                     pDosEntry( 0 ),
79cdf0e10cSrcweir                     pParent( 0 ),
80cdf0e10cSrcweir 					aPath( GUI2FSYS(rDir.GetFull()) ),
81cdf0e10cSrcweir                     bReady ( sal_False ),
82cdf0e10cSrcweir 					bInUse( sal_False )
83cdf0e10cSrcweir                 {
84cdf0e10cSrcweir #ifndef BOOTSTRAP
85cdf0e10cSrcweir 					// Redirection
86cdf0e10cSrcweir 					FSysRedirector::DoRedirect( aPath );
87cdf0e10cSrcweir #endif
88cdf0e10cSrcweir 
89cdf0e10cSrcweir                     // nur den String der Memer-Var nehmen!
90cdf0e10cSrcweir 
91cdf0e10cSrcweir #if defined(UNX) || defined(OS2) //for further exlpanation see DirReader_Impl::Read() in unx.cxx
92cdf0e10cSrcweir 					pDosDir = NULL;
93cdf0e10cSrcweir #else
94cdf0e10cSrcweir                     aBypass = ByteString(aPath, osl_getThreadTextEncoding());
95cdf0e10cSrcweir                     pDosDir = opendir( (char*) aBypass.GetBuffer() );
96cdf0e10cSrcweir #endif
97cdf0e10cSrcweir 
98cdf0e10cSrcweir                     // Parent f"ur die neuen DirEntries ermitteln
99cdf0e10cSrcweir 					pParent = pDir->GetFlag() == FSYS_FLAG_NORMAL ||
100cdf0e10cSrcweir 							  pDir->GetFlag() == FSYS_FLAG_ABSROOT
101cdf0e10cSrcweir 									? pDir
102cdf0e10cSrcweir 									: pDir->GetParent();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir                 }
105cdf0e10cSrcweir 
~DirReader_ImplDirReader_Impl106cdf0e10cSrcweir                 ~DirReader_Impl()
107cdf0e10cSrcweir                 { if( pDosDir ) closedir( pDosDir ); }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir                 // die folgenden sind systemabh"angig implementiert
110cdf0e10cSrcweir     sal_uInt16      Init(); // initialisiert, liest ggf. devices
111cdf0e10cSrcweir     sal_uInt16      Read(); // liest 1 Eintrag, F2ugt ein falls ok
112cdf0e10cSrcweir };
113cdf0e10cSrcweir 
114cdf0e10cSrcweir //--------------------------------------------------------------------
115cdf0e10cSrcweir 
116cdf0e10cSrcweir struct FileCopier_Impl
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	FSysAction		nActions;		// was zu tun ist (Copy/Move/recur)
119cdf0e10cSrcweir     Link            aErrorLink;		// bei Fehlern zu rufen
120cdf0e10cSrcweir 	ErrCode			eErr;           // aktueller Fehlercode im Error-Handler
121cdf0e10cSrcweir 	const DirEntry*	pErrSource;		// fuer Error-Handler falls Source-Fehler
122cdf0e10cSrcweir 	const DirEntry*	pErrTarget;		// fuer Error-Handler falls Target-Fehler
123cdf0e10cSrcweir 
FileCopier_ImplFileCopier_Impl124cdf0e10cSrcweir 					FileCopier_Impl()
125cdf0e10cSrcweir 					:	nActions( 0 ), eErr( 0 ),
126cdf0e10cSrcweir 						pErrSource( 0 ), pErrTarget( 0 )
127cdf0e10cSrcweir 					{}
FileCopier_ImplFileCopier_Impl128cdf0e10cSrcweir 					FileCopier_Impl( const FileCopier_Impl &rOrig )
129cdf0e10cSrcweir 					:	nActions( rOrig.nActions ), eErr( 0 ),
130cdf0e10cSrcweir 						pErrSource( 0 ), pErrTarget( 0 )
131cdf0e10cSrcweir 					{}
132cdf0e10cSrcweir 
operator =FileCopier_Impl133cdf0e10cSrcweir 	FileCopier_Impl& operator=( const FileCopier_Impl &rOrig )
134cdf0e10cSrcweir 					{
135cdf0e10cSrcweir 						nActions = rOrig.nActions;
136cdf0e10cSrcweir 						eErr = 0; pErrSource = 0; pErrTarget = 0;
137cdf0e10cSrcweir 						return *this;
138cdf0e10cSrcweir 					}
139cdf0e10cSrcweir };
140cdf0e10cSrcweir 
141cdf0e10cSrcweir //--------------------------------------------------------------------
142cdf0e10cSrcweir 
143cdf0e10cSrcweir #if defined WNT || defined OS2
144cdf0e10cSrcweir sal_Bool IsRedirectable_Impl( const ByteString &rPath );
145cdf0e10cSrcweir #else
146cdf0e10cSrcweir #define IsRedirectable_Impl( rPath )	sal_True
147cdf0e10cSrcweir #endif
148cdf0e10cSrcweir 
149cdf0e10cSrcweir //--------------------------------------------------------------------
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 
152cdf0e10cSrcweir #endif
153