2 // This file is part of the aMule Project.
4 // Copyright (c) 2008-2011 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Any parts of this program derived from the xMule, lMule or eMule project,
7 // or contributed by third-party developers are copyrighted by their
10 // This program is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 2 of the License, or
13 // (at your option) any later version.
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #ifndef PLATFORMSPECIFIC_H
26 #define PLATFORMSPECIFIC_H
28 #include <common/Path.h>
32 namespace PlatformSpecific
{
38 * This function will create the named file sparse if possible.
40 * @param name The file to be created (sparse if possible).
41 * @param size The desired size of the file.
42 * @return true, if creating the file succeeded, false otherwise.
44 bool CreateSparseFile(const CPath
& name
, uint64_t size
);
48 * Returns the max number of connections the current OS can handle.
50 * Currently anything but windows will return the default value (-1);
53 int GetMaxConnections();
55 inline int GetMaxConnections() { return -1; }
60 * File system types returned by GetFilesystemType
63 fsFAT
, //! File Allocation Table
64 fsNTFS
, //! New Technology File System
65 fsHFS
, //! Hierarchical File System
66 fsHPFS
, //! High Performace File System
67 fsMINIX
, //! Minix file system
68 fsOther
//! Unknown, other
72 * Find out the filesystem type of the given path.
74 * @param path The path for which the filesystem type should be checked.
75 * @return The filesystem type of the given path.
77 * This function returns fsOther on unknown or network file systems (because the
78 * real filesystem type cannot be determined).
80 EFSType
GetFilesystemType(const CPath
& path
);
84 * Checks if the filesystem can handle special chars.
86 * @param path The path for which the file system should be checked.
87 * @return true if the underlying filesystem can handle special chars.
89 * This function checks if the file system of the given path can handle
90 * special chars e.g. ':' in file names. This function will always return
91 * false on MSW, since Windows cannot handle those characters on any file system.
93 * Based on http://en.wikipedia.org/wiki/Comparison_of_file_systems
96 inline bool CanFSHandleSpecialChars(const CPath
& WXUNUSED(path
)) { return false; }
98 // Other filesystem types may be added
99 inline bool CanFSHandleSpecialChars(const CPath
& path
)
101 switch (GetFilesystemType(path
)) {
114 * Check if the filesystem can handle large files.
116 * @param path The path for which the filesystem should be checked.
117 * @return true if the underlying filesystem can handle large files.
119 * This function checks if the file system of the given path can handle
120 * large files (>4GB).
122 * Based on http://en.wikipedia.org/wiki/Comparison_of_file_systems
124 inline bool CanFSHandleLargeFiles(const CPath
& path
)
126 switch (GetFilesystemType(path
)) {
138 * Disable / enable computer's energy saving "standby" mode.
141 #if defined __WINDOWS__ || defined __WXMAC__
142 #define PLATFORMSPECIFIC_CAN_PREVENT_SLEEP_MODE 1
144 #define PLATFORMSPECIFIC_CAN_PREVENT_SLEEP_MODE 0
147 void PreventSleepMode();
148 void AllowSleepMode();
150 }; /* namespace PlatformSpecific */
152 #endif /* PLATFORMSPECIFIC_H */