xref: /aoo4110/main/tools/source/fsys/comdep.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _COMDEP_HXX
25 #define _COMDEP_HXX
26 
27 #include <tools/fsys.hxx>
28 
29 #define ACCESSDELIM(e)  ( (e == FSYS_STYLE_MAC) ? ":" : \
30 						( ( e == FSYS_STYLE_VFAT || e == FSYS_STYLE_HPFS || \
31 						    e == FSYS_STYLE_FAT ) || e == FSYS_STYLE_NTFS ) \
32 						  ? "\\" : "/" )
33 #define ACCESSDELIM_C(e)(char)\
34                         ( (e == FSYS_STYLE_MAC) ? ':' : \
35 						( ( e == FSYS_STYLE_VFAT || e == FSYS_STYLE_HPFS || \
36 						    e == FSYS_STYLE_FAT ) || e == FSYS_STYLE_NTFS ) \
37 						  ? '\\' : '/' )
38 #define SEARCHDELIM(e)  ( (e == FSYS_STYLE_SYSV || e == FSYS_STYLE_BSD) ? ":" \
39                         : ";" )
40 #define SEARCHDELIM_C(e)(char)\
41                         ( (e == FSYS_STYLE_SYSV || e == FSYS_STYLE_BSD) ? ':' \
42                         : ';' )
43 #define ACTPARENT(e)    ( (e == FSYS_STYLE_MAC) ? ":" : ".." )
44 #define ACTCURRENT(e)   ( (e == FSYS_STYLE_MAC) ? "" : "." )
45 
46 #if defined UNX
47 #include "unx.hxx"
48 #elif defined WNT
49 #include "wntmsc.hxx"
50 #elif defined OS2
51 #include "os2.hxx"
52 #endif
53 
54 //--------------------------------------------------------------------
55 
56 #ifndef LINUX
57 DIR *opendir( const char* pPfad );
58 dirent *readdir( DIR *pDir );
59 int closedir( DIR *pDir );
60 char *volumeid( const char* pPfad );
61 #endif
62 
63 //--------------------------------------------------------------------
64 
65 struct DirReader_Impl
66 {
67 	Dir*		pDir;
68     DIR*        pDosDir;
69     dirent*     pDosEntry;
70     DirEntry*   pParent;
71     String  	aPath;
72     ByteString  aBypass;
73     sal_Bool        bReady;
74 	sal_Bool		bInUse;
75 
DirReader_ImplDirReader_Impl76 				DirReader_Impl( Dir &rDir )
77 				:	pDir( &rDir ),
78                     pDosEntry( 0 ),
79                     pParent( 0 ),
80 					aPath( GUI2FSYS(rDir.GetFull()) ),
81                     bReady ( sal_False ),
82 					bInUse( sal_False )
83                 {
84 #ifndef BOOTSTRAP
85 					// Redirection
86 					FSysRedirector::DoRedirect( aPath );
87 #endif
88 
89                     // nur den String der Memer-Var nehmen!
90 
91 #if defined(UNX) || defined(OS2) //for further exlpanation see DirReader_Impl::Read() in unx.cxx
92 					pDosDir = NULL;
93 #else
94                     aBypass = ByteString(aPath, osl_getThreadTextEncoding());
95                     pDosDir = opendir( (char*) aBypass.GetBuffer() );
96 #endif
97 
98                     // Parent f"ur die neuen DirEntries ermitteln
99 					pParent = pDir->GetFlag() == FSYS_FLAG_NORMAL ||
100 							  pDir->GetFlag() == FSYS_FLAG_ABSROOT
101 									? pDir
102 									: pDir->GetParent();
103 
104                 }
105 
~DirReader_ImplDirReader_Impl106                 ~DirReader_Impl()
107                 { if( pDosDir ) closedir( pDosDir ); }
108 
109                 // die folgenden sind systemabh"angig implementiert
110     sal_uInt16      Init(); // initialisiert, liest ggf. devices
111     sal_uInt16      Read(); // liest 1 Eintrag, F2ugt ein falls ok
112 };
113 
114 //--------------------------------------------------------------------
115 
116 struct FileCopier_Impl
117 {
118 	FSysAction		nActions;		// was zu tun ist (Copy/Move/recur)
119     Link            aErrorLink;		// bei Fehlern zu rufen
120 	ErrCode			eErr;           // aktueller Fehlercode im Error-Handler
121 	const DirEntry*	pErrSource;		// fuer Error-Handler falls Source-Fehler
122 	const DirEntry*	pErrTarget;		// fuer Error-Handler falls Target-Fehler
123 
FileCopier_ImplFileCopier_Impl124 					FileCopier_Impl()
125 					:	nActions( 0 ), eErr( 0 ),
126 						pErrSource( 0 ), pErrTarget( 0 )
127 					{}
FileCopier_ImplFileCopier_Impl128 					FileCopier_Impl( const FileCopier_Impl &rOrig )
129 					:	nActions( rOrig.nActions ), eErr( 0 ),
130 						pErrSource( 0 ), pErrTarget( 0 )
131 					{}
132 
operator =FileCopier_Impl133 	FileCopier_Impl& operator=( const FileCopier_Impl &rOrig )
134 					{
135 						nActions = rOrig.nActions;
136 						eErr = 0; pErrSource = 0; pErrTarget = 0;
137 						return *this;
138 					}
139 };
140 
141 //--------------------------------------------------------------------
142 
143 #if defined WNT || defined OS2
144 sal_Bool IsRedirectable_Impl( const ByteString &rPath );
145 #else
146 #define IsRedirectable_Impl( rPath )	sal_True
147 #endif
148 
149 //--------------------------------------------------------------------
150 
151 
152 #endif
153