2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
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
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.
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"
36 // Dir iterator: needed because wxWidget's wxFindNextFile and
37 // wxFindFirstFile are bugged like hell.
38 class CDirIterator
: private wxDir
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
);
52 CPath
GetFirstFile(FileType type
, const wxString
& mask
= wxEmptyString
);
55 bool HasSubDirs(const wxString
& spec
= wxEmptyString
);
59 //! Filetypes understood by UnpackArchive
62 //! Text files, will be left unchanged.
64 //! Zip archive, will be unpacked
66 //! GZip archives, will be unpacked
68 //! Met file, will be left unchanged.
70 //! Unknown filetype, will be left unchanged.
72 //! This is returned when trying to unpack a broken archive.
77 typedef std::pair
<bool, EFileType
> UnpackResult
;
80 * Unpacks a single file from an archive, replacing the archive.
82 * @param file The archive.
83 * @param files An array of filenames (terminated by a NULL entry) which should be unpacked.
84 * @return The first value is true if the archive was unpacked, the second is the resulting filetype.
86 * If the file specified is not an archive, it will be left unchanged and
87 * the file-type returned. If it is a GZip archive, the archive will be
88 * unpacked and the new file will replace the archive. If the archive is a
89 * Zip archive, the first file found matching any in the files array (case-
90 * insensitive) will be unpacked and overwrite the archive.
92 UnpackResult
UnpackArchive(const CPath
& file
, const wxChar
* files
[]);
95 // File_checked_for_headers