1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#ifndef FILEUTILITIES_H
#define FILEUTILITIES_H
#include <list>
#include <string>
#include <set>
#include "PathNameUtility.h"
#include "DateTime.h"
#include "File.h"
using std::string;
#if UNITY_EDITOR
/// Returns the real pathname of path
/// (eg. if pathname is all lowercase, the returned string will match the actual pathname)
/// If there is no file at path returns path.
std::string GetActualPathSlow (const std::string & input);
std::string GetActualAbsolutePathSlow (const std::string & path);
// Copies a file or folder. Resolves all symlinks in from before copying.
bool CopyFileOrDirectory (const string& from, const string& to);
bool MoveToTrash (const string& path);
bool CopyReplaceFile (string from, string to);
bool MoveFileOrDirectory (const string& fromPath, const string& toPath);
string GetProjectRelativePath (const string& path);
bool CreateDirectory (const string& pathName);
/// Returns a set of files and folders that are deep children of the folder at pathname.
/// Ignores invisible files
bool GetDeepFolderContentsAtPath (const string& pathName, std::set<string>& paths);
/// Returns the content modification date for the file at path or zero timestamp if file couldn't be found
DateTime GetContentModificationDate (const string& path);
/// Sets the content modification date (write time) for the file at path
bool SetContentModificationDateToCurrentTime (const string& path);
bool CreateDirectorySafe (const string& pathName);
std::string GenerateUniquePath (std::string inPath);
std::string GenerateUniquePathSafe (const std::string& pathName);
std::string GetUniqueTempPathInProject ();
std::string GetUniqueTempPath (const std::string& basePath);
bool IsPathCreated (const std::string& path);
#if UNITY_OSX || UNITY_LINUX
inline void UnixTimeToUnityTime (time_t time, DateTime &dateTime )
{
// Seconds from 1904 to 2001: 3061152000 (kCFAbsoluteTimeIntervalSince1904)
// Seconds from 1970 to 2001: 978307200 (kCFAbsoluteTimeIntervalSince1970)
// Thus seconds from 1904 to 1970: 2082844800
UInt64 seconds = time - 2082844800;
dateTime.fraction = 0;
dateTime.lowSeconds = seconds & 0xFFFFFFFF;
dateTime.highSeconds = seconds >> 32;
}
#endif
#if UNITY_OSX
bool PathToFSSpec (const std::string& path, FSSpec* spec);
#endif
#if UNITY_WIN
void FileTimeToUnityTime( const FILETIME& ft, DateTime& dateTime );
bool CopyFileOrDirectoryCheckPermissions (const string& from, const string& to, bool &accessdenied);
#endif
enum AtomicWriteMode {
kProjectTempFolder = 0,
#if UNITY_OSX
kSystemTempFolder = 1,
#endif
kNotAtomic = 2,
};
bool WriteStringToFile (const string& inData, const string& pathName, AtomicWriteMode mode, UInt32 fileFlags);
bool IsSymlink (const std::string& pathName);
// Resolve symlinks & canonicalize the path
std::string ResolveSymlinks (const std::string& pathName);
std::string GetUserAppDataFolder ();
std::string GetUserAppCacheFolder ();
#endif // UNITY_EDITOR
string GetApplicationPath ();
string GetApplicationContentsPath ();
string GetApplicationFolder ();
string GetApplicationLocalFolder();
string GetApplicationManagedPath();
string GetApplicationTemporaryFolder();
#if UNITY_STANDALONE || UNITY_EDITOR
string GetApplicationNativeLibsPath();
#endif
bool CreateFile (const string& path, int creator = '?', int fileType = '?');
#if UNITY_LINUX || UNITY_BB10 || UNITY_TIZEN
void SetApplicationPath( std::string path );
bool IsSymlink(const std::string &pathName);
std::string ResolveSymlink(const std::string& pathName);
#if !UNITY_BB10 && !UNITY_TIZEN
std::string GetUserConfigFolder ();
#endif
#endif
#endif
|