Upstream tarball 20080304
[amule.git] / src / libs / common / FileFunctions.h
blob969ab1650befcfe45443c528bcd29219374af58c
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #ifndef FILEFUNCTIONS_H
28 #define FILEFUNCTIONS_H
30 #include "../../Types.h"
31 #include "Path.h"
33 #include <wx/dir.h>
36 // Dir iterator: needed because wxWidget's wxFindNextFile and
37 // wxFindFirstFile are bugged like hell.
38 class CDirIterator : private wxDir
40 public:
41 enum FileType {
42 FileNoHidden = wxDIR_FILES,
43 DirNoHidden = wxDIR_DIRS,
44 File = wxDIR_FILES | wxDIR_HIDDEN,
45 Dir = wxDIR_DIRS | wxDIR_HIDDEN,
46 Any = wxDIR_FILES | wxDIR_DIRS | wxDIR_HIDDEN
49 CDirIterator(const CPath& dir);
50 ~CDirIterator();
52 CPath GetFirstFile(FileType type, const wxString& mask = wxEmptyString);
53 CPath GetNextFile();
55 bool HasSubDirs(const wxString& spec = wxEmptyString);
59 //! Filetypes understood by UnpackArchive
60 enum EFileType
62 //! Text files, will be left unchanged.
63 EFT_Text,
64 //! Zip archive, will be unpacked
65 EFT_Zip,
66 //! GZip archives, will be unpacked
67 EFT_GZip,
68 //! Met file, will be left unchanged.
69 EFT_Met,
70 //! Unknown filetype, will be left unchanged.
71 EFT_Unknown
75 typedef std::pair<bool, EFileType> UnpackResult;
77 /**
78 * Unpacks a single file from an archive, replacing the archive.
80 * @param file The archive.
81 * @param files An array of filenames (terminated by a NULL entry) which should be unpacked.
82 * @return The first value is true if the archive was unpacked, the second is the resulting filetype.
84 * If the file specified is not an archive, it will be left unchanged and
85 * the file-type returned. If it is a GZip archive, the archive will be
86 * unpacked and the new file will replace the archive. If the archive is a
87 * Zip archive, the first file found matching any in the files array (case-
88 * insensitive) will be unpacked and overwrite the archive.
90 UnpackResult UnpackArchive(const CPath& file, const wxChar* files[]);
93 enum FSCheckResult {
94 //! The file-system is FAT32, so certain chars have to be stripped.
95 FS_IsFAT32,
96 //! The file-system is not FAT32.
97 FS_NotFAT32,
98 //! Failed to check the specified file-system.
99 FS_Failed
104 * Checks if the specified path is on a FAT32 file-system.
106 * Note that CheckFileSystem always returns FS_IsFAT32 on wxMSW.
108 FSCheckResult CheckFileSystem(const CPath& path);
111 #endif
112 // File_checked_for_headers