Ticket #514: mac_watchdir.patch
File mac_watchdir.patch, 34.7 KB (added by , 11 years ago) |
---|
-
libraries/source/fcollada/src/FCollada/FColladaTest/RunFColladaTests/RunFColladaTests.cs
29 29 30 30 // test for file existence 31 31 String fullName = path + exe; 32 FileInfo file = newFileInfo( fullName );32 CFileInfo file = new CFileInfo( fullName ); 33 33 34 34 Assert.IsTrue( file.Exists, "Unable to find executable : " + fullName ); 35 35 … … 50 50 String procErr = proc.StandardError.ReadToEnd(); 51 51 Assert.IsTrue( (procErr.Length == 0), procErr ); 52 52 53 FileInfo outFile = newFileInfo( path + outputName );53 CFileInfo outFile = new CFileInfo( path + outputName ); 54 54 55 55 // test for outFile existence 56 56 Assert.IsTrue( outFile.Exists, exe + " was unable to create output file." ); -
source/graphics/ColladaManager.cpp
185 185 { 186 186 // Include skeletons.xml file info in the hash 187 187 VfsPath skeletonPath("art/skeletons/skeletons.xml"); 188 FileInfo fileInfo;188 CFileInfo fileInfo; 189 189 190 190 // This will cause an assertion failure if skeletons.xml doesn't exist, 191 191 // because fileinfo is not a NULL pointer, which is annoying but that -
source/lib/file/archive/archive.h
55 55 * called for each archive entry. 56 56 * @param pathname full pathname of entry; only valid during the callback. 57 57 **/ 58 typedef void (*ArchiveEntryCallback)(const VfsPath& pathname, const FileInfo& fileInfo, PIArchiveFile archiveFile, uintptr_t cbData);58 typedef void (*ArchiveEntryCallback)(const VfsPath& pathname, const CFileInfo& fileInfo, PIArchiveFile archiveFile, uintptr_t cbData); 59 59 virtual Status ReadEntries(ArchiveEntryCallback cb, uintptr_t cbData) = 0; 60 60 }; 61 61 -
source/lib/file/archive/archive_builder.cpp
141 141 // optimizations like reading from vfs_tree container directly. 142 142 class FileGatherer 143 143 { 144 static void EntCb(const char* path, const FileInfo* ent, uintptr_t cbData)144 static void EntCb(const char* path, const CFileInfo* ent, uintptr_t cbData) 145 145 { 146 146 FileNodes* file_nodes = (FileNodes*)cbData; 147 147 … … 544 544 archive_ext = path_extension(archive_fn); 545 545 } 546 546 547 bool operator()( FileInfo& ent) const547 bool operator()(CFileInfo& ent) const 548 548 { 549 549 // remove if not file 550 550 if(ent.IsDirectory) -
source/lib/file/archive/archive_zip.cpp
109 109 class LFH 110 110 { 111 111 public: 112 void Init(const FileInfo& fileInfo, off_t csize, ZipMethod method, u32 checksum, const Path& pathname)112 void Init(const CFileInfo& fileInfo, off_t csize, ZipMethod method, u32 checksum, const Path& pathname) 113 113 { 114 114 const std::string pathnameUTF8 = utf8_from_wstring(pathname.string()); 115 115 const size_t pathnameSize = pathnameUTF8.length(); … … 157 157 class CDFH 158 158 { 159 159 public: 160 void Init(const FileInfo& fileInfo, off_t ofs, off_t csize, ZipMethod method, u32 checksum, const Path& pathname, size_t slack)160 void Init(const CFileInfo& fileInfo, off_t ofs, off_t csize, ZipMethod method, u32 checksum, const Path& pathname, size_t slack) 161 161 { 162 162 const std::string pathnameUTF8 = utf8_from_wstring(pathname.string()); 163 163 const size_t pathnameLength = pathnameUTF8.length(); … … 415 415 416 416 PFile m_file; 417 417 418 // all relevant LFH/CDFH fields not covered by FileInfo418 // all relevant LFH/CDFH fields not covered by CFileInfo 419 419 mutable off_t m_ofs; 420 420 off_t m_csize; 421 421 u32 m_checksum; … … 434 434 ArchiveReader_Zip(const OsPath& pathname) 435 435 : m_file(new File(pathname, O_RDONLY)) 436 436 { 437 FileInfo fileInfo;437 CFileInfo fileInfo; 438 438 GetFileInfo(pathname, &fileInfo); 439 439 m_fileSize = fileInfo.Size(); 440 440 const size_t minFileSize = sizeof(LFH)+sizeof(CDFH)+sizeof(ECDR); … … 466 466 if(!relativePathname.IsDirectory()) 467 467 { 468 468 const OsPath name = relativePathname.Filename(); 469 FileInfo fileInfo(name, cdfh->USize(), cdfh->MTime());469 CFileInfo fileInfo(name, cdfh->USize(), cdfh->MTime()); 470 470 shared_ptr<ArchiveFile_Zip> archiveFile(new ArchiveFile_Zip(m_file, cdfh->HeaderOffset(), cdfh->CSize(), cdfh->Checksum(), cdfh->Method())); 471 471 cb(relativePathname, fileInfo, archiveFile, cbData); 472 472 } … … 612 612 613 613 Status AddFile(const OsPath& pathname, const OsPath& pathnameInArchive) 614 614 { 615 FileInfo fileInfo;615 CFileInfo fileInfo; 616 616 RETURN_STATUS_IF_ERR(GetFileInfo(pathname, &fileInfo)); 617 617 618 618 PFile file(new File); … … 623 623 624 624 Status AddMemory(const u8* data, size_t size, time_t mtime, const OsPath& pathnameInArchive) 625 625 { 626 FileInfo fileInfo(pathnameInArchive, size, mtime);626 CFileInfo fileInfo(pathnameInArchive, size, mtime); 627 627 628 628 return AddFileOrMemory(fileInfo, pathnameInArchive, PFile(), data); 629 629 } 630 630 631 Status AddFileOrMemory(const FileInfo& fileInfo, const OsPath& pathnameInArchive, const PFile& file, const u8* data)631 Status AddFileOrMemory(const CFileInfo& fileInfo, const OsPath& pathnameInArchive, const PFile& file, const u8* data) 632 632 { 633 633 ENSURE((file && !data) || (data && !file)); 634 634 -
source/lib/file/file_system.cpp
62 62 } 63 63 64 64 65 Status GetFileInfo(const OsPath& pathname, FileInfo* pfileInfo)65 Status GetFileInfo(const OsPath& pathname, CFileInfo* pPtrInfo) 66 66 { 67 67 errno = 0; 68 68 struct stat s; … … 70 70 if(wstat(pathname, &s) != 0) 71 71 WARN_RETURN(StatusFromErrno()); 72 72 73 *p fileInfo =FileInfo(pathname.Filename(), s.st_size, s.st_mtime);73 *pPtrInfo = CFileInfo(pathname.Filename(), s.st_size, s.st_mtime); 74 74 return INFO::OK; 75 75 } 76 76 … … 84 84 } 85 85 }; 86 86 87 Status GetDirectoryEntries(const OsPath& path, FileInfos* files, DirectoryNames* subdirectoryNames)87 Status GetDirectoryEntries(const OsPath& path, CFileInfos* files, DirectoryNames* subdirectoryNames) 88 88 { 89 89 // open directory 90 90 errno = 0; … … 123 123 #endif 124 124 125 125 if(files && S_ISREG(s.st_mode)) 126 files->push_back( FileInfo(name, s.st_size, s.st_mtime));126 files->push_back(CFileInfo(name, s.st_size, s.st_mtime)); 127 127 else if(subdirectoryNames && S_ISDIR(s.st_mode) && name != L"." && name != L"..") 128 128 subdirectoryNames->push_back(name); 129 129 } … … 166 166 // note: we have to recursively empty the directory before it can 167 167 // be deleted (required by Windows and POSIX rmdir()). 168 168 169 FileInfos files; DirectoryNames subdirectoryNames;169 CFileInfos files; DirectoryNames subdirectoryNames; 170 170 RETURN_STATUS_IF_ERR(GetDirectoryEntries(path, &files, &subdirectoryNames)); 171 171 172 172 // delete files -
source/lib/file/file_system.h
38 38 39 39 40 40 // (bundling size and mtime avoids a second expensive call to stat()) 41 class FileInfo41 class CFileInfo 42 42 { 43 43 public: 44 FileInfo()44 CFileInfo() 45 45 { 46 46 } 47 47 48 FileInfo(const OsPath& name, off_t size, time_t mtime)48 CFileInfo(const OsPath& name, off_t size, time_t mtime) 49 49 : name(name), size(size), mtime(mtime) 50 50 { 51 51 } … … 71 71 time_t mtime; 72 72 }; 73 73 74 LIB_API Status GetFileInfo(const OsPath& pathname, FileInfo* fileInfo);74 LIB_API Status GetFileInfo(const OsPath& pathname, CFileInfo* fileInfo); 75 75 76 typedef std::vector< FileInfo>FileInfos;76 typedef std::vector<CFileInfo> CFileInfos; 77 77 typedef std::vector<OsPath> DirectoryNames; 78 78 79 LIB_API Status GetDirectoryEntries(const OsPath& path, FileInfos* files, DirectoryNames* subdirectoryNames);79 LIB_API Status GetDirectoryEntries(const OsPath& path, CFileInfos* files, DirectoryNames* subdirectoryNames); 80 80 81 81 // same as boost::filesystem::create_directories, except that mkdir is invoked with 82 82 // <mode> instead of 0755. -
source/lib/file/vfs/vfs.cpp
77 77 return INFO::OK; 78 78 } 79 79 80 virtual Status GetFileInfo(const VfsPath& pathname, FileInfo* pfileInfo) const80 virtual Status GetFileInfo(const VfsPath& pathname, CFileInfo* pfileInfo) const 81 81 { 82 82 ScopedLock s; 83 83 VfsDirectory* directory; VfsFile* file; … … 85 85 if(!pfileInfo) // just indicate if the file exists without raising warnings. 86 86 return ret; 87 87 WARN_RETURN_STATUS_IF_ERR(ret); 88 *pfileInfo = FileInfo(file->Name(), file->Size(), file->MTime());88 *pfileInfo = CFileInfo(file->Name(), file->Size(), file->MTime()); 89 89 return INFO::OK; 90 90 } 91 91 … … 98 98 return INFO::OK; 99 99 } 100 100 101 virtual Status GetDirectoryEntries(const VfsPath& path, FileInfos* fileInfos, DirectoryNames* subdirectoryNames) const101 virtual Status GetDirectoryEntries(const VfsPath& path, CFileInfos* fileInfos, DirectoryNames* subdirectoryNames) const 102 102 { 103 103 ScopedLock s; 104 104 VfsDirectory* directory; … … 112 112 for(VfsDirectory::VfsFiles::const_iterator it = files.begin(); it != files.end(); ++it) 113 113 { 114 114 const VfsFile& file = it->second; 115 fileInfos->push_back( FileInfo(file.Name(), file.Size(), file.MTime()));115 fileInfos->push_back(CFileInfo(file.Name(), file.Size(), file.MTime())); 116 116 } 117 117 } 118 118 … … 229 229 { 230 230 ScopedLock s; 231 231 VfsDirectory* directory; VfsFile* file; 232 232 233 WARN_RETURN_STATUS_IF_ERR(vfs_Lookup(pathname, &m_rootDirectory, directory, &file)); 233 234 realPathname = file->Loader()->Path() / pathname.Filename(); 234 235 return INFO::OK; -
source/lib/file/vfs/vfs.h
28 28 #ifndef INCLUDED_VFS 29 29 #define INCLUDED_VFS 30 30 31 #include "lib/file/file_system.h" // FileInfo31 #include "lib/file/file_system.h" // CFileInfo 32 32 #include "lib/file/vfs/vfs_path.h" 33 33 34 34 namespace ERR … … 109 109 * 110 110 * @return Status. 111 111 **/ 112 virtual Status GetFileInfo(const VfsPath& pathname, FileInfo* pfileInfo) const = 0;112 virtual Status GetFileInfo(const VfsPath& pathname, CFileInfo* pfileInfo) const = 0; 113 113 114 114 /** 115 115 * Retrieve mount priority for a file. … … 132 132 * - we cannot efficiently provide routines for returning files and 133 133 * subdirectories separately due to the underlying POSIX interface. 134 134 **/ 135 virtual Status GetDirectoryEntries(const VfsPath& path, FileInfos* fileInfos, DirectoryNames* subdirectoryNames) const = 0;135 virtual Status GetDirectoryEntries(const VfsPath& path, CFileInfos* fileInfos, DirectoryNames* subdirectoryNames) const = 0; 136 136 137 137 /** 138 138 * Create a file with the given contents. -
source/lib/file/vfs/vfs_lookup.cpp
28 28 #include "lib/file/vfs/vfs_lookup.h" 29 29 30 30 #include "lib/external_libraries/suppress_boost_warnings.h" 31 #include "ps/CLogger.h" 31 32 32 33 #include "lib/sysdep/filesystem.h" 33 34 #include "lib/file/vfs/vfs.h" // error codes … … 109 110 if(addMissingDirectories) 110 111 subdirectory = directory->AddSubdirectory(subdirectoryName); 111 112 else 112 return ERR::VFS_DIR_NOT_FOUND; // NOWARN 113 { 114 return ERR::VFS_DIR_NOT_FOUND; // NOWARN 115 } 113 116 } 114 117 115 118 if(createMissingDirectories && (!subdirectory->AssociatedDirectory() … … 138 141 const VfsPath filename = pathname.string().substr(pos); 139 142 *pfile = directory->GetFile(filename); 140 143 if(!*pfile) 141 return ERR::VFS_FILE_NOT_FOUND; // NOWARN 144 { 145 return ERR::VFS_FILE_NOT_FOUND; // NOWARN 146 } 142 147 } 143 148 144 149 return INFO::OK; -
source/lib/file/vfs/vfs_populate.cpp
41 41 42 42 struct CompareFileInfoByName 43 43 { 44 bool operator()(const FileInfo& a, constFileInfo& b)44 bool operator()(const CFileInfo& a, const CFileInfo& b) 45 45 { 46 46 return a.Name() < b.Name(); 47 47 } … … 64 64 s_looseFiles.reserve(10000); 65 65 #endif 66 66 67 FileInfos files; files.reserve(500);67 CFileInfos files; files.reserve(500); 68 68 DirectoryNames subdirectoryNames; subdirectoryNames.reserve(50); 69 69 RETURN_STATUS_IF_ERR(GetDirectoryEntries(m_realDirectory->Path(), &files, &subdirectoryNames)); 70 70 … … 82 82 } 83 83 84 84 private: 85 void AddFile(const FileInfo& fileInfo) const85 void AddFile(const CFileInfo& fileInfo) const 86 86 { 87 87 const VfsPath name = fileInfo.Name(); 88 88 if(name.Extension() == L".DELETED") … … 108 108 #endif 109 109 } 110 110 111 static void AddArchiveFile(const VfsPath& pathname, const FileInfo& fileInfo, PIArchiveFile archiveFile, uintptr_t cbData)111 static void AddArchiveFile(const VfsPath& pathname, const CFileInfo& fileInfo, PIArchiveFile archiveFile, uintptr_t cbData) 112 112 { 113 113 PopulateHelper* this_ = (PopulateHelper*)cbData; 114 114 … … 133 133 #endif 134 134 } 135 135 136 Status AddFiles(const FileInfos& files) const136 Status AddFiles(const CFileInfos& files) const 137 137 { 138 138 const OsPath path(m_realDirectory->Path()); 139 139 -
source/lib/file/vfs/vfs_tree.h
29 29 30 30 #include <map> 31 31 32 #include "lib/file/file_system.h" // FileInfo32 #include "lib/file/file_system.h" // CFileInfo 33 33 #include "lib/file/common/file_loader.h" // PIFileLoader 34 34 #include "lib/file/common/real_directory.h" // PRealDirectory 35 35 #include "lib/file/vfs/vfs_path.h" -
source/lib/file/vfs/vfs_util.cpp
39 39 40 40 Status GetPathnames(const PIVFS& fs, const VfsPath& path, const wchar_t* filter, VfsPaths& pathnames) 41 41 { 42 std::vector< FileInfo> files;42 std::vector<CFileInfo> files; 43 43 RETURN_STATUS_IF_ERR(fs->GetDirectoryEntries(path, &files, 0)); 44 44 45 45 pathnames.clear(); … … 58 58 Status ForEachFile(const PIVFS& fs, const VfsPath& startPath, FileCallback cb, uintptr_t cbData, const wchar_t* pattern, size_t flags) 59 59 { 60 60 // (declare here to avoid reallocations) 61 FileInfos files; DirectoryNames subdirectoryNames;61 CFileInfos files; DirectoryNames subdirectoryNames; 62 62 63 63 // (a FIFO queue is more efficient than recursion because it uses less 64 64 // stack space and avoids seeks due to breadth-first traversal.) … … 72 72 73 73 for(size_t i = 0; i < files.size(); i++) 74 74 { 75 const FileInfo fileInfo = files[i];75 const CFileInfo fileInfo = files[i]; 76 76 if(!match_wildcard(fileInfo.Name().string().c_str(), pattern)) 77 77 continue; 78 78 79 const VfsPath pathname(path / fileInfo.Name()); // ( FileInfo only stores the name)79 const VfsPath pathname(path / fileInfo.Name()); // (CFileInfo only stores the name) 80 80 cb(pathname, fileInfo, cbData); 81 81 } 82 82 … … 105 105 const VfsPath path = pathnameFormat.Parent()/""; 106 106 107 107 size_t maxNumber = 0; 108 FileInfos files;108 CFileInfos files; 109 109 fs->GetDirectoryEntries(path, &files, 0); 110 110 for(size_t i = 0; i < files.size(); i++) 111 111 { -
source/lib/file/vfs/vfs_util.h
37 37 /** 38 38 * called for files in a directory. 39 39 * 40 * @param pathname full pathname (since FileInfo only gives the name).40 * @param pathname full pathname (since CFileInfo only gives the name). 41 41 * @param fileInfo file information 42 42 * @param cbData user-specified context 43 43 * @return INFO::CONTINUE on success; any other value will immediately … … 46 46 * CAVEAT: pathname and fileInfo are only valid until the function 47 47 * returns! 48 48 **/ 49 typedef Status (*FileCallback)(const VfsPath& pathname, const FileInfo& fileInfo, const uintptr_t cbData);49 typedef Status (*FileCallback)(const VfsPath& pathname, const CFileInfo& fileInfo, const uintptr_t cbData); 50 50 51 51 enum DirFlags 52 52 { -
source/lib/sysdep/os/osx/dir_watch.cpp
21 21 */ 22 22 23 23 #include "precompiled.h" 24 24 25 #include "lib/sysdep/dir_watch.h" 26 #include "lib/file/file_system.h" 27 #include "osx_sys_version.h" 25 28 26 // stub implementations 29 #include "lib/os_path.h" 30 #include "lib/file/file.h" 31 #include "lib/posix/posix_filesystem.h" // mode_t 27 32 28 Status dir_watch_Add(const OsPath& UNUSED(path), PDirWatch& UNUSED(dirWatch)) 33 #include <CoreFoundation/CoreFoundation.h> 34 #include <CoreServices/CoreServices.h> 35 36 37 #include "ps/CLogger.h" 38 39 FSEventStreamRef g_Stream = NULL; 40 41 typedef std::vector<CFileInfo> CFileInfos; 42 43 struct DirWatch 29 44 { 45 OsPath path; 46 int reqnum; 47 }; 48 49 typedef std::map<std::string, time_t> FolderModDateList; 50 typedef std::vector<DirWatch> DirWatchMap; 51 static DirWatchMap g_Paths; 52 static DirWatchMap g_RootPaths; 53 static DirWatchNotifications g_QueuedDirs; 54 static FolderModDateList g_FolderMods; 55 static time_t g_ListenStartTime = NULL; 56 57 58 std::wstring StringToWString(const std::string& s) 59 { 60 std::wstring temp(s.length(),L' '); 61 std::copy(s.begin(), s.end(), temp.begin()); 62 return temp; 63 } 64 bool CanRunNotifications() 65 { 66 int major = 0; 67 int minor = 0; 68 int bugfix = 0; 69 70 GetSystemVersion( major, minor, bugfix); 71 72 if ((major == 10 && minor >= 7) || major >= 11) 73 return true; 74 75 return false; 76 } 77 78 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 79 #define FlagFileEventsSubstitute kFSEventStreamCreateFlagFileEvents 80 #else 81 #define FlagFileEventsSubstitute 0x00000000 82 #endif 83 84 static void mycallback( 85 ConstFSEventStreamRef UNUSED(streamRef), 86 void * UNUSED(clientCallBackInfo), 87 size_t numEvents, 88 void *eventPaths, 89 const FSEventStreamEventFlags eventFlags[], 90 const FSEventStreamEventId eventIds[]) 91 { 92 unsigned long i; 93 char **paths = (char **)eventPaths; 94 95 for (i=0; i<numEvents; i++) 96 { 97 bool isWatched = false; 98 OsPath tesr = OsPath(paths[i]); 99 100 if ( tesr.Filename().string().c_str()[0] != '.' ) 101 { 102 for ( DirWatchMap::iterator it = g_Paths.begin() ; it != g_Paths.end(); ++it) 103 if ( wcsncmp( it->path.string().c_str(), tesr.Parent().string().c_str(), it->path.string().length() ) == 0 ) 104 isWatched = true; 105 } 106 107 if ( isWatched ) 108 { 109 110 OsPath filename = Path( tesr.string().c_str() ); 111 unsigned long creationEvent = (kFSEventStreamEventFlagItemCreated | kFSEventStreamEventFlagItemIsFile); 112 unsigned long deletionEvent = (kFSEventStreamEventFlagItemRemoved | kFSEventStreamEventFlagItemIsFile); 113 unsigned long trashEvent = (kFSEventStreamEventFlagItemRenamed | kFSEventStreamEventFlagItemIsFile); 114 unsigned long modifyEvent = (kFSEventStreamEventFlagItemModified | kFSEventStreamEventFlagItemIsFile); 115 116 if ( ((unsigned long)eventFlags[i] & deletionEvent ) == deletionEvent ) 117 { 118 g_QueuedDirs.push_back(DirWatchNotification( filename.string().c_str(), DirWatchNotification::Deleted )); 119 break; 120 } 121 else if ( ((unsigned long)eventFlags[i] & trashEvent ) == trashEvent ) 122 { 123 g_QueuedDirs.push_back(DirWatchNotification( filename.string().c_str(), DirWatchNotification::Deleted )); 124 break; 125 } 126 else if ( ((unsigned long)eventFlags[i] & creationEvent ) == creationEvent ) 127 { 128 g_QueuedDirs.push_back(DirWatchNotification( filename.string().c_str(), DirWatchNotification::Created )); 129 break; 130 } 131 else if ( ((unsigned long)eventFlags[i] & modifyEvent ) == modifyEvent ) 132 { 133 g_QueuedDirs.push_back(DirWatchNotification( filename.string().c_str(), DirWatchNotification::Changed )); 134 break; 135 } 136 } 137 } 138 } 139 140 FSEventStreamRef CreateEventStream( DirWatchMap path ) 141 { 142 if ( ( g_Stream == NULL ) && CanRunNotifications() ) 143 { 144 CFStringEncoding encoding = (CFByteOrderLittleEndian == CFByteOrderGetCurrent()) ? kCFStringEncodingUTF32LE : kCFStringEncodingUTF32BE; 145 CFStringRef* pathLists = (CFStringRef*)malloc( sizeof(CFStringRef*) * path.size() ); 146 int index = 0; 147 for ( DirWatchMap::iterator it = path.begin() ; it != path.end(); ++it) 148 { 149 LOGERROR( L"root path watched %ls\n", it->path.string().c_str() ); 150 pathLists[index] = CFStringCreateWithBytes( NULL, (const UInt8*)it->path.string().c_str(), 151 wcslen(it->path.string().c_str()) * sizeof(wchar_t), encoding, false); 152 index++; 153 } 154 CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)pathLists, index, NULL); 155 156 FSEventStreamContext *callbackInfo = NULL; 157 158 FSEventStreamRef stream = FSEventStreamCreate(NULL, &mycallback, callbackInfo, pathsToWatch, 159 kFSEventStreamEventIdSinceNow, 1.0, FlagFileEventsSubstitute ); 160 161 g_ListenStartTime = time(0); 162 163 FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); 164 if (!FSEventStreamStart(stream)) 165 debug_warn(L"event_loop FSEventStreamStart failed!"); 166 else 167 return stream; 168 } 169 return NULL; 170 } 171 172 Status dir_watch_Add(const OsPath& path, PDirWatch& dirWatch) 173 { 174 PDirWatch tmpDirWatch(new DirWatch); 175 dirWatch.swap(tmpDirWatch); 176 dirWatch->path = path; 177 dirWatch->reqnum = 0; 178 g_Paths.push_back( *dirWatch ); 179 180 bool alreadyInsideRootPath = false; 181 for ( DirWatchMap::iterator it = g_RootPaths.begin() ; it != g_RootPaths.end(); ++it) 182 { 183 if ( path.string().compare(0, it->path.string().length(), it->path.string() ) == 0 ) 184 alreadyInsideRootPath = true; 185 } 186 if ( !alreadyInsideRootPath ) 187 { 188 g_RootPaths.push_back( *dirWatch ); 189 } 190 30 191 return INFO::OK; 31 192 } 32 193 33 Status dir_watch_Poll(DirWatchNotifications& UNUSED(notifications))194 Status dir_watch_Poll(DirWatchNotifications& notifications) 34 195 { 196 if ( g_Stream == NULL ) 197 { 198 g_Stream = CreateEventStream( g_RootPaths ); 199 } 200 else 201 { 202 for ( DirWatchNotifications::iterator it = g_QueuedDirs.begin() ; it != g_QueuedDirs.end(); ++it) 203 notifications.push_back(DirWatchNotification( *it )); 204 205 g_QueuedDirs.clear(); 206 } 207 35 208 return INFO::OK; 36 209 } -
source/lib/sysdep/os/osx/osx_sys_version.h
1 #ifndef OSX_SYS_VERSION_H 2 #define OSX_SYS_VERSION_H 3 4 5 6 7 8 9 10 11 void GetSystemVersion( int &major, int &minor, int &bugfix ); 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #endif //OSX_SYS_VERSION_H 26 No newline at end of file -
source/lib/sysdep/os/osx/osx_sys_version.mm
1 #import <AvailabilityMacros.h> // MAC_OS_X_VERSION_MIN_REQUIRED 2 #import <Foundation/Foundation.h> 3 #import <string> 4 5 #import "osx_bundle.h" 6 7 #define STRINGIZE2(id) # id 8 #define STRINGIZE(id) STRINGIZE2(id) 9 10 // Pass the bundle identifier string as a build option 11 #ifdef BUNDLE_IDENTIFIER 12 static const char* BUNDLE_ID_STR = STRINGIZE(BUNDLE_IDENTIFIER); 13 #else 14 static const char* BUNDLE_ID_STR = ""; 15 #endif 16 17 18 void GetSystemVersion( int &major, int &minor, int &bugfix ) 19 { 20 // sensible default 21 static int mMajor = 10; 22 static int mMinor = 8; 23 static int mBugfix = 0; 24 25 static dispatch_once_t onceToken; 26 dispatch_once(&onceToken, ^{ 27 NSString* versionString = [[NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"] objectForKey:@"ProductVersion"]; 28 NSArray* versions = [versionString componentsSeparatedByString:@"."]; 29 check( versions.count >= 2 ); 30 if ( versions.count >= 1 ) { 31 mMajor = [versions[0] integerValue]; 32 } 33 if ( versions.count >= 2 ) { 34 mMinor = [versions[1] integerValue]; 35 } 36 if ( versions.count >= 3 ) { 37 mBugfix = [versions[2] integerValue]; 38 } 39 }); 40 41 major = mMajor; 42 minor = mMinor; 43 bugfix = mBugfix; 44 } -
source/ps/ArchiveBuilder.cpp
173 173 } 174 174 } 175 175 176 Status CArchiveBuilder::CollectFileCB(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)176 Status CArchiveBuilder::CollectFileCB(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData) 177 177 { 178 178 CArchiveBuilder* self = static_cast<CArchiveBuilder*>((void*)cbData); 179 179 self->m_Files.push_back(pathname); -
source/ps/ArchiveBuilder.h
57 57 void Build(const OsPath& archive, bool compress); 58 58 59 59 private: 60 static Status CollectFileCB(const VfsPath& pathname, const FileInfo& fileInfo, const uintptr_t cbData);60 static Status CollectFileCB(const VfsPath& pathname, const CFileInfo& fileInfo, const uintptr_t cbData); 61 61 62 62 PIVFS m_VFS; 63 63 std::vector<VfsPath> m_Files; -
source/ps/CacheLoader.cpp
95 95 96 96 // If source file is more recent than the archive cache (i.e. the user has edited it), 97 97 // don't use the old cache 98 FileInfo sourceInfo, archiveCacheInfo;98 CFileInfo sourceInfo, archiveCacheInfo; 99 99 if (m_VFS->GetFileInfo(sourcePath, &sourceInfo) >= 0 && 100 100 m_VFS->GetFileInfo(archiveCachePath, &archiveCacheInfo) >= 0) 101 101 { … … 116 116 117 117 VfsPath CCacheLoader::LooseCachePath(const VfsPath& sourcePath, const MD5& initialHash, u32 version) 118 118 { 119 FileInfo fileInfo;119 CFileInfo fileInfo; 120 120 if (m_VFS->GetFileInfo(sourcePath, &fileInfo) < 0) 121 121 { 122 122 debug_warn(L"source file disappeared"); // this should never happen -
source/ps/SavedGame.cpp
87 87 archiveWriter.reset(); // close the file 88 88 89 89 WriteBuffer buffer; 90 FileInfo tempSaveFile;90 CFileInfo tempSaveFile; 91 91 WARN_RETURN_STATUS_IF_ERR(GetFileInfo(tempSaveFileRealPath, &tempSaveFile)); 92 92 buffer.Reserve(tempSaveFile.Size()); 93 93 WARN_RETURN_STATUS_IF_ERR(io::Load(tempSaveFileRealPath, buffer.Data().get(), buffer.Size())); … … 112 112 { 113 113 } 114 114 115 static void ReadEntryCallback(const VfsPath& pathname, const FileInfo& fileInfo, PIArchiveFile archiveFile, uintptr_t cbData)115 static void ReadEntryCallback(const VfsPath& pathname, const CFileInfo& fileInfo, PIArchiveFile archiveFile, uintptr_t cbData) 116 116 { 117 117 ((CGameLoader*)cbData)->ReadEntry(pathname, fileInfo, archiveFile); 118 118 } 119 119 120 void ReadEntry(const VfsPath& pathname, const FileInfo& fileInfo, PIArchiveFile archiveFile)120 void ReadEntry(const VfsPath& pathname, const CFileInfo& fileInfo, PIArchiveFile archiveFile) 121 121 { 122 122 if (pathname == L"metadata.json" && m_Metadata) 123 123 { -
source/ps/scripting/JSInterface_VFS.cpp
66 66 }; 67 67 68 68 // called for each matching directory entry; add its full pathname to array. 69 static Status BuildDirEntListCB(const VfsPath& pathname, const FileInfo& UNUSED(fileINfo), uintptr_t cbData)69 static Status BuildDirEntListCB(const VfsPath& pathname, const CFileInfo& UNUSED(fileINfo), uintptr_t cbData) 70 70 { 71 71 BuildDirEntListState* s = (BuildDirEntListState*)cbData; 72 72 … … 140 140 if (!ToPrimitive<CStrW> (cx, JS_ARGV(cx, vp)[0], filename)) 141 141 return JS_FALSE; 142 142 143 FileInfo fileInfo;143 CFileInfo fileInfo; 144 144 Status err = g_VFS->GetFileInfo(filename, &fileInfo); 145 145 JS_CHECK_FILE_ERR(err); 146 146 … … 161 161 if (!ToPrimitive<CStrW> (cx, JS_ARGV(cx, vp)[0], filename)) 162 162 return JS_FALSE; 163 163 164 FileInfo fileInfo;164 CFileInfo fileInfo; 165 165 Status err = g_VFS->GetFileInfo(filename, &fileInfo); 166 166 JS_CHECK_FILE_ERR(err); 167 167 -
source/scriptinterface/DebuggingServer.cpp
176 176 } 177 177 178 178 179 static Status AddFileResponse(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)179 static Status AddFileResponse(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData) 180 180 { 181 181 std::vector<std::string>& templates = *(std::vector<std::string>*)cbData; 182 182 std::wstring str(pathname.string()); -
source/simulation2/components/CCmpTemplateManager.cpp
429 429 CParamNode::LoadXMLString(out, xml.c_str(), actorNameW.c_str()); 430 430 } 431 431 432 static Status AddToTemplates(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)432 static Status AddToTemplates(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData) 433 433 { 434 434 std::vector<std::string>& templates = *(std::vector<std::string>*)cbData; 435 435 … … 446 446 return INFO::OK; 447 447 } 448 448 449 static Status AddActorToTemplates(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)449 static Status AddActorToTemplates(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData) 450 450 { 451 451 std::vector<std::string>& templates = *(std::vector<std::string>*)cbData; 452 452 -
source/simulation2/components/ICmpAIManager.cpp
47 47 vfs::ForEachFile(g_VFS, L"simulation/ai/", Callback, (uintptr_t)this, L"*.json", vfs::DIR_RECURSIVE); 48 48 } 49 49 50 static Status Callback(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)50 static Status Callback(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData) 51 51 { 52 52 GetAIsHelper* self = (GetAIsHelper*)cbData; 53 53 -
source/simulation2/system/ComponentManager.cpp
961 961 return componentManager->GetScriptInterface().ReadJSONFile(path).get(); 962 962 } 963 963 964 Status CComponentManager::FindJSONFilesCallback(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)964 Status CComponentManager::FindJSONFilesCallback(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData) 965 965 { 966 966 FindJSONFilesCallbackData* data = (FindJSONFilesCallbackData*)cbData; 967 967 -
source/simulation2/system/ComponentManager.h
245 245 static CScriptVal ReadJSONFile(void *cbdata, std::wstring filePath, std::wstring fileName); 246 246 247 247 // callback function to handle recursively finding files in a directory 248 static Status FindJSONFilesCallback(const VfsPath&, const FileInfo&, const uintptr_t);248 static Status FindJSONFilesCallback(const VfsPath&, const CFileInfo&, const uintptr_t); 249 249 250 250 CMessage* ConstructMessage(int mtid, CScriptVal data); 251 251 void SendGlobalMessage(entity_id_t ent, const CMessage& msg) const; -
source/soundmanager/SoundManager.cpp
20 20 #include "ISoundManager.h" 21 21 #include "SoundManager.h" 22 22 23 #include "ps/Filesystem.h" 24 23 25 #include "soundmanager/data/SoundData.h" 24 26 #include "soundmanager/items/CSoundItem.h" 25 27 #include "soundmanager/items/CBufferItem.h" … … 235 237 al_ReportError(err, caller, line); 236 238 } 237 239 240 Status CSoundManager::ReloadChangedFiles(const VfsPath& path) 241 { 242 // LOGERROR(L"GUI file '%ls' changed - reloading page", path.string().c_str()); 243 244 return INFO::OK; 245 } 246 /*static*/ Status CSoundManager::ReloadChangedFileCB(void* param, const VfsPath& path) 247 { 248 return static_cast<CSoundManager*>(param)->ReloadChangedFiles(path); 249 } 250 238 251 CSoundManager::CSoundManager() 239 252 { 240 253 m_CurrentEnvirons = 0; … … 277 290 m_Worker = new CSoundManagerWorker(); 278 291 m_Worker->SetEnabled( true ); 279 292 } 293 294 RegisterFileReloadFunc(ReloadChangedFileCB, this); 280 295 } 281 296 282 297 CSoundManager::~CSoundManager() 283 298 { 299 UnregisterFileReloadFunc(ReloadChangedFileCB, this); 300 284 301 if (m_Worker ) 285 302 { 286 303 AL_CHECK -
source/soundmanager/SoundManager.h
102 102 ISoundItem* ItemForData(CSoundData* itemData); 103 103 ISoundItem* ItemForEntity( entity_id_t source, CSoundData* sndData); 104 104 105 Status ReloadChangedFiles(const VfsPath& path); 106 105 107 void ClearPlayListItems(); 106 108 void StartPlayList( bool doLoop ); 107 109 void AddPlayListItem( const VfsPath* itemPath); … … 109 111 static void ScriptingInit(); 110 112 static void CreateSoundManager(); 111 113 static void SetEnabled(bool doEnable); 112 114 static Status ReloadChangedFileCB(void* param, const VfsPath& path); 115 113 116 static void al_ReportError(ALenum err, const char* caller, int line); 114 117 static void al_check(const char* caller, int line); 115 118