Fix the changelog wikifier script to properly handle multi-line entries
[amule.git] / src / PlatformSpecific.h
blob42e10718f5604d929e7d014210d7fd173fad3aa8
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2008-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5 //
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
8 // respective authors.
9 //
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>
29 #include "Types.h"
32 namespace PlatformSpecific {
35 /**
36 * Create sparse file.
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);
47 /**
48 * Returns the max number of connections the current OS can handle.
50 * Currently anything but windows will return the default value (-1);
52 #ifdef __WINDOWS__
53 int GetMaxConnections();
54 #else
55 inline int GetMaxConnections() { return -1; }
56 #endif
59 /**
60 * File system types returned by GetFilesystemType
62 enum EFSType {
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
71 /**
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);
83 /**
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
95 #ifdef __WINDOWS__
96 inline bool CanFSHandleSpecialChars(const CPath& WXUNUSED(path)) { return false; }
97 #else
98 // Other filesystem types may be added
99 inline bool CanFSHandleSpecialChars(const CPath& path)
101 switch (GetFilesystemType(path)) {
102 case fsFAT:
103 case fsNTFS:
104 case fsHFS:
105 return false;
106 default:
107 return true;
110 #endif
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)) {
127 case fsFAT:
128 case fsHFS:
129 case fsHPFS:
130 case fsMINIX:
131 return false;
132 default:
133 return true;
138 * Disable / enable computer's energy saving "standby" mode.
141 #if defined __WINDOWS__ || defined __WXMAC__
142 #define PLATFORMSPECIFIC_CAN_PREVENT_SLEEP_MODE 1
143 #else
144 #define PLATFORMSPECIFIC_CAN_PREVENT_SLEEP_MODE 0
145 #endif
147 void PreventSleepMode();
148 void AllowSleepMode();
150 }; /* namespace PlatformSpecific */
152 #endif /* PLATFORMSPECIFIC_H */