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