Ticket #514: mac_watchdir.patch

File mac_watchdir.patch, 34.7 KB (added by stwf, 11 years ago)

FileInfo and mac watchdir patch

  • libraries/source/fcollada/src/FCollada/FColladaTest/RunFColladaTests/RunFColladaTests.cs

     
    2929
    3030            // test for file existence
    3131            String fullName = path + exe;
    32             FileInfo file = new FileInfo( fullName );
     32            CFileInfo file = new CFileInfo( fullName );
    3333           
    3434            Assert.IsTrue( file.Exists, "Unable to find executable : " + fullName );
    3535
     
    5050            String procErr = proc.StandardError.ReadToEnd();
    5151            Assert.IsTrue( (procErr.Length == 0), procErr );
    5252
    53             FileInfo outFile = new FileInfo( path + outputName );
     53            CFileInfo outFile = new CFileInfo( path + outputName );
    5454
    5555            // test for outFile existence
    5656            Assert.IsTrue( outFile.Exists, exe + " was unable to create output file." );
  • source/graphics/ColladaManager.cpp

     
    185185{
    186186    // Include skeletons.xml file info in the hash
    187187    VfsPath skeletonPath("art/skeletons/skeletons.xml");
    188     FileInfo fileInfo;
     188    CFileInfo fileInfo;
    189189
    190190    // This will cause an assertion failure if skeletons.xml doesn't exist,
    191191    //  because fileinfo is not a NULL pointer, which is annoying but that
  • source/lib/file/archive/archive.h

     
    5555     * called for each archive entry.
    5656     * @param pathname full pathname of entry; only valid during the callback.
    5757     **/
    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);
    5959    virtual Status ReadEntries(ArchiveEntryCallback cb, uintptr_t cbData) = 0;
    6060};
    6161
  • source/lib/file/archive/archive_builder.cpp

     
    141141// optimizations like reading from vfs_tree container directly.
    142142class FileGatherer
    143143{
    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)
    145145    {
    146146        FileNodes* file_nodes = (FileNodes*)cbData;
    147147
     
    544544        archive_ext = path_extension(archive_fn);
    545545    }
    546546
    547     bool operator()(FileInfo& ent) const
     547    bool operator()(CFileInfo& ent) const
    548548    {
    549549        // remove if not file
    550550        if(ent.IsDirectory)
  • source/lib/file/archive/archive_zip.cpp

     
    109109class LFH
    110110{
    111111public:
    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)
    113113    {
    114114        const std::string pathnameUTF8 = utf8_from_wstring(pathname.string());
    115115        const size_t pathnameSize = pathnameUTF8.length();
     
    157157class CDFH
    158158{
    159159public:
    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)
    161161    {
    162162        const std::string pathnameUTF8 = utf8_from_wstring(pathname.string());
    163163        const size_t pathnameLength = pathnameUTF8.length();
     
    415415
    416416    PFile m_file;
    417417
    418     // all relevant LFH/CDFH fields not covered by FileInfo
     418    // all relevant LFH/CDFH fields not covered by CFileInfo
    419419    mutable off_t m_ofs;
    420420    off_t m_csize;
    421421    u32 m_checksum;
     
    434434    ArchiveReader_Zip(const OsPath& pathname)
    435435        : m_file(new File(pathname, O_RDONLY))
    436436    {
    437         FileInfo fileInfo;
     437        CFileInfo fileInfo;
    438438        GetFileInfo(pathname, &fileInfo);
    439439        m_fileSize = fileInfo.Size();
    440440        const size_t minFileSize = sizeof(LFH)+sizeof(CDFH)+sizeof(ECDR);
     
    466466            if(!relativePathname.IsDirectory())
    467467            {
    468468                const OsPath name = relativePathname.Filename();
    469                 FileInfo fileInfo(name, cdfh->USize(), cdfh->MTime());
     469                CFileInfo fileInfo(name, cdfh->USize(), cdfh->MTime());
    470470                shared_ptr<ArchiveFile_Zip> archiveFile(new ArchiveFile_Zip(m_file, cdfh->HeaderOffset(), cdfh->CSize(), cdfh->Checksum(), cdfh->Method()));
    471471                cb(relativePathname, fileInfo, archiveFile, cbData);
    472472            }
     
    612612
    613613    Status AddFile(const OsPath& pathname, const OsPath& pathnameInArchive)
    614614    {
    615         FileInfo fileInfo;
     615        CFileInfo fileInfo;
    616616        RETURN_STATUS_IF_ERR(GetFileInfo(pathname, &fileInfo));
    617617
    618618        PFile file(new File);
     
    623623
    624624    Status AddMemory(const u8* data, size_t size, time_t mtime, const OsPath& pathnameInArchive)
    625625    {
    626         FileInfo fileInfo(pathnameInArchive, size, mtime);
     626        CFileInfo fileInfo(pathnameInArchive, size, mtime);
    627627
    628628        return AddFileOrMemory(fileInfo, pathnameInArchive, PFile(), data);
    629629    }
    630630
    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)
    632632    {
    633633        ENSURE((file && !data) || (data && !file));
    634634
  • source/lib/file/file_system.cpp

     
    6262}
    6363
    6464
    65 Status GetFileInfo(const OsPath& pathname, FileInfo* pfileInfo)
     65Status GetFileInfo(const OsPath& pathname, CFileInfo* pPtrInfo)
    6666{
    6767    errno = 0;
    6868    struct stat s;
     
    7070    if(wstat(pathname, &s) != 0)
    7171        WARN_RETURN(StatusFromErrno());
    7272
    73     *pfileInfo = FileInfo(pathname.Filename(), s.st_size, s.st_mtime);
     73    *pPtrInfo = CFileInfo(pathname.Filename(), s.st_size, s.st_mtime);
    7474    return INFO::OK;
    7575}
    7676
     
    8484    }
    8585};
    8686
    87 Status GetDirectoryEntries(const OsPath& path, FileInfos* files, DirectoryNames* subdirectoryNames)
     87Status GetDirectoryEntries(const OsPath& path, CFileInfos* files, DirectoryNames* subdirectoryNames)
    8888{
    8989    // open directory
    9090    errno = 0;
     
    123123#endif
    124124
    125125        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));
    127127        else if(subdirectoryNames && S_ISDIR(s.st_mode) && name != L"." && name != L"..")
    128128            subdirectoryNames->push_back(name);
    129129    }
     
    166166    // note: we have to recursively empty the directory before it can
    167167    // be deleted (required by Windows and POSIX rmdir()).
    168168
    169     FileInfos files; DirectoryNames subdirectoryNames;
     169    CFileInfos files; DirectoryNames subdirectoryNames;
    170170    RETURN_STATUS_IF_ERR(GetDirectoryEntries(path, &files, &subdirectoryNames));
    171171
    172172    // delete files
  • source/lib/file/file_system.h

     
    3838
    3939
    4040// (bundling size and mtime avoids a second expensive call to stat())
    41 class FileInfo
     41class CFileInfo
    4242{
    4343public:
    44     FileInfo()
     44    CFileInfo()
    4545    {
    4646    }
    4747
    48     FileInfo(const OsPath& name, off_t size, time_t mtime)
     48    CFileInfo(const OsPath& name, off_t size, time_t mtime)
    4949        : name(name), size(size), mtime(mtime)
    5050    {
    5151    }
     
    7171    time_t mtime;
    7272};
    7373
    74 LIB_API Status GetFileInfo(const OsPath& pathname, FileInfo* fileInfo);
     74LIB_API Status GetFileInfo(const OsPath& pathname, CFileInfo* fileInfo);
    7575
    76 typedef std::vector<FileInfo> FileInfos;
     76typedef std::vector<CFileInfo> CFileInfos;
    7777typedef std::vector<OsPath> DirectoryNames;
    7878
    79 LIB_API Status GetDirectoryEntries(const OsPath& path, FileInfos* files, DirectoryNames* subdirectoryNames);
     79LIB_API Status GetDirectoryEntries(const OsPath& path, CFileInfos* files, DirectoryNames* subdirectoryNames);
    8080
    8181// same as boost::filesystem::create_directories, except that mkdir is invoked with
    8282// <mode> instead of 0755.
  • source/lib/file/vfs/vfs.cpp

     
    7777        return INFO::OK;
    7878    }
    7979
    80     virtual Status GetFileInfo(const VfsPath& pathname, FileInfo* pfileInfo) const
     80    virtual Status GetFileInfo(const VfsPath& pathname, CFileInfo* pfileInfo) const
    8181    {
    8282        ScopedLock s;
    8383        VfsDirectory* directory; VfsFile* file;
     
    8585        if(!pfileInfo)  // just indicate if the file exists without raising warnings.
    8686            return ret;
    8787        WARN_RETURN_STATUS_IF_ERR(ret);
    88         *pfileInfo = FileInfo(file->Name(), file->Size(), file->MTime());
     88        *pfileInfo = CFileInfo(file->Name(), file->Size(), file->MTime());
    8989        return INFO::OK;
    9090    }
    9191
     
    9898        return INFO::OK;
    9999    }
    100100
    101     virtual Status GetDirectoryEntries(const VfsPath& path, FileInfos* fileInfos, DirectoryNames* subdirectoryNames) const
     101    virtual Status GetDirectoryEntries(const VfsPath& path, CFileInfos* fileInfos, DirectoryNames* subdirectoryNames) const
    102102    {
    103103        ScopedLock s;
    104104        VfsDirectory* directory;
     
    112112            for(VfsDirectory::VfsFiles::const_iterator it = files.begin(); it != files.end(); ++it)
    113113            {
    114114                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()));
    116116            }
    117117        }
    118118
     
    229229    {
    230230        ScopedLock s;
    231231        VfsDirectory* directory; VfsFile* file;
     232       
    232233        WARN_RETURN_STATUS_IF_ERR(vfs_Lookup(pathname, &m_rootDirectory, directory, &file));
    233234        realPathname = file->Loader()->Path() / pathname.Filename();
    234235        return INFO::OK;
  • source/lib/file/vfs/vfs.h

     
    2828#ifndef INCLUDED_VFS
    2929#define INCLUDED_VFS
    3030
    31 #include "lib/file/file_system.h"   // FileInfo
     31#include "lib/file/file_system.h"   // CFileInfo
    3232#include "lib/file/vfs/vfs_path.h"
    3333
    3434namespace ERR
     
    109109     *
    110110     * @return Status.
    111111     **/
    112     virtual Status GetFileInfo(const VfsPath& pathname, FileInfo* pfileInfo) const = 0;
     112    virtual Status GetFileInfo(const VfsPath& pathname, CFileInfo* pfileInfo) const = 0;
    113113
    114114    /**
    115115     * Retrieve mount priority for a file.
     
    132132     * - we cannot efficiently provide routines for returning files and
    133133     *   subdirectories separately due to the underlying POSIX interface.
    134134     **/
    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;
    136136
    137137    /**
    138138     * Create a file with the given contents.
  • source/lib/file/vfs/vfs_lookup.cpp

     
    2828#include "lib/file/vfs/vfs_lookup.h"
    2929
    3030#include "lib/external_libraries/suppress_boost_warnings.h"
     31#include "ps/CLogger.h"
    3132
    3233#include "lib/sysdep/filesystem.h"
    3334#include "lib/file/vfs/vfs.h"   // error codes
     
    109110            if(addMissingDirectories)
    110111                subdirectory = directory->AddSubdirectory(subdirectoryName);
    111112            else
    112                 return ERR::VFS_DIR_NOT_FOUND;  // NOWARN
     113            {
     114                    return ERR::VFS_DIR_NOT_FOUND;  // NOWARN
     115            }
    113116        }
    114117
    115118        if(createMissingDirectories && (!subdirectory->AssociatedDirectory()
     
    138141        const VfsPath filename = pathname.string().substr(pos);
    139142        *pfile = directory->GetFile(filename);
    140143        if(!*pfile)
    141             return ERR::VFS_FILE_NOT_FOUND; // NOWARN
     144        {
     145                return ERR::VFS_FILE_NOT_FOUND; // NOWARN
     146        }
    142147    }
    143148
    144149    return INFO::OK;
  • source/lib/file/vfs/vfs_populate.cpp

     
    4141
    4242struct CompareFileInfoByName
    4343{
    44     bool operator()(const FileInfo& a, const FileInfo& b)
     44    bool operator()(const CFileInfo& a, const CFileInfo& b)
    4545    {
    4646        return a.Name() < b.Name();
    4747    }
     
    6464        s_looseFiles.reserve(10000);
    6565#endif
    6666
    67         FileInfos files; files.reserve(500);
     67        CFileInfos files; files.reserve(500);
    6868        DirectoryNames subdirectoryNames; subdirectoryNames.reserve(50);
    6969        RETURN_STATUS_IF_ERR(GetDirectoryEntries(m_realDirectory->Path(), &files, &subdirectoryNames));
    7070
     
    8282    }
    8383
    8484private:
    85     void AddFile(const FileInfo& fileInfo) const
     85    void AddFile(const CFileInfo& fileInfo) const
    8686    {
    8787        const VfsPath name = fileInfo.Name();
    8888        if(name.Extension() == L".DELETED")
     
    108108#endif
    109109    }
    110110
    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)
    112112    {
    113113        PopulateHelper* this_ = (PopulateHelper*)cbData;
    114114
     
    133133#endif
    134134    }
    135135
    136     Status AddFiles(const FileInfos& files) const
     136    Status AddFiles(const CFileInfos& files) const
    137137    {
    138138        const OsPath path(m_realDirectory->Path());
    139139
  • source/lib/file/vfs/vfs_tree.h

     
    2929
    3030#include <map>
    3131
    32 #include "lib/file/file_system.h"   // FileInfo
     32#include "lib/file/file_system.h"   // CFileInfo
    3333#include "lib/file/common/file_loader.h"    // PIFileLoader
    3434#include "lib/file/common/real_directory.h" // PRealDirectory
    3535#include "lib/file/vfs/vfs_path.h"
  • source/lib/file/vfs/vfs_util.cpp

     
    3939
    4040Status GetPathnames(const PIVFS& fs, const VfsPath& path, const wchar_t* filter, VfsPaths& pathnames)
    4141{
    42     std::vector<FileInfo> files;
     42    std::vector<CFileInfo> files;
    4343    RETURN_STATUS_IF_ERR(fs->GetDirectoryEntries(path, &files, 0));
    4444
    4545    pathnames.clear();
     
    5858Status ForEachFile(const PIVFS& fs, const VfsPath& startPath, FileCallback cb, uintptr_t cbData, const wchar_t* pattern, size_t flags)
    5959{
    6060    // (declare here to avoid reallocations)
    61     FileInfos files; DirectoryNames subdirectoryNames;
     61    CFileInfos files; DirectoryNames subdirectoryNames;
    6262
    6363    // (a FIFO queue is more efficient than recursion because it uses less
    6464    // stack space and avoids seeks due to breadth-first traversal.)
     
    7272
    7373        for(size_t i = 0; i < files.size(); i++)
    7474        {
    75             const FileInfo fileInfo = files[i];
     75            const CFileInfo fileInfo = files[i];
    7676            if(!match_wildcard(fileInfo.Name().string().c_str(), pattern))
    7777                continue;
    7878
    79             const VfsPath pathname(path / fileInfo.Name()); // (FileInfo only stores the name)
     79            const VfsPath pathname(path / fileInfo.Name()); // (CFileInfo only stores the name)
    8080            cb(pathname, fileInfo, cbData);
    8181        }
    8282
     
    105105        const VfsPath path = pathnameFormat.Parent()/"";
    106106
    107107        size_t maxNumber = 0;
    108         FileInfos files;
     108        CFileInfos files;
    109109        fs->GetDirectoryEntries(path, &files, 0);
    110110        for(size_t i = 0; i < files.size(); i++)
    111111        {
  • source/lib/file/vfs/vfs_util.h

     
    3737/**
    3838 * called for files in a directory.
    3939 *
    40  * @param pathname full pathname (since FileInfo only gives the name).
     40 * @param pathname full pathname (since CFileInfo only gives the name).
    4141 * @param fileInfo file information
    4242 * @param cbData user-specified context
    4343 * @return INFO::CONTINUE on success; any other value will immediately
     
    4646 * CAVEAT: pathname and fileInfo are only valid until the function
    4747 * returns!
    4848 **/
    49 typedef Status (*FileCallback)(const VfsPath& pathname, const FileInfo& fileInfo, const uintptr_t cbData);
     49typedef Status (*FileCallback)(const VfsPath& pathname, const CFileInfo& fileInfo, const uintptr_t cbData);
    5050
    5151enum DirFlags
    5252{
  • source/lib/sysdep/os/osx/dir_watch.cpp

     
    2121 */
    2222
    2323#include "precompiled.h"
     24
    2425#include "lib/sysdep/dir_watch.h"
     26#include "lib/file/file_system.h"
     27#include "osx_sys_version.h"
    2528
    26 // stub implementations
     29#include "lib/os_path.h"
     30#include "lib/file/file.h"
     31#include "lib/posix/posix_filesystem.h" // mode_t
    2732
    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
     39FSEventStreamRef    g_Stream = NULL;
     40
     41typedef std::vector<CFileInfo> CFileInfos;
     42
     43struct DirWatch
    2944{
     45  OsPath path;
     46  int reqnum;
     47};
     48
     49typedef std::map<std::string, time_t> FolderModDateList;
     50typedef std::vector<DirWatch> DirWatchMap;
     51static DirWatchMap g_Paths;
     52static DirWatchMap g_RootPaths;
     53static DirWatchNotifications g_QueuedDirs;
     54static FolderModDateList g_FolderMods;
     55static time_t g_ListenStartTime = NULL;
     56
     57
     58std::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}
     64bool  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
     84static 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
     140FSEventStreamRef 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
     172Status 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
    30191    return INFO::OK;
    31192}
    32193
    33 Status dir_watch_Poll(DirWatchNotifications& UNUSED(notifications))
     194Status dir_watch_Poll(DirWatchNotifications& notifications)
    34195{
     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
    35208    return INFO::OK;
    36209}
  • 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
     11void 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
     12static const char* BUNDLE_ID_STR = STRINGIZE(BUNDLE_IDENTIFIER);
     13#else
     14static const char* BUNDLE_ID_STR = "";
     15#endif
     16
     17
     18void 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

     
    173173    }
    174174}
    175175
    176 Status CArchiveBuilder::CollectFileCB(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)
     176Status CArchiveBuilder::CollectFileCB(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData)
    177177{
    178178    CArchiveBuilder* self = static_cast<CArchiveBuilder*>((void*)cbData);
    179179    self->m_Files.push_back(pathname);
  • source/ps/ArchiveBuilder.h

     
    5757    void Build(const OsPath& archive, bool compress);
    5858
    5959private:
    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);
    6161
    6262    PIVFS m_VFS;
    6363    std::vector<VfsPath> m_Files;
  • source/ps/CacheLoader.cpp

     
    9595
    9696    // If source file is more recent than the archive cache (i.e. the user has edited it),
    9797    // don't use the old cache
    98     FileInfo sourceInfo, archiveCacheInfo;
     98    CFileInfo sourceInfo, archiveCacheInfo;
    9999    if (m_VFS->GetFileInfo(sourcePath, &sourceInfo) >= 0 &&
    100100        m_VFS->GetFileInfo(archiveCachePath, &archiveCacheInfo) >= 0)
    101101    {
     
    116116
    117117VfsPath CCacheLoader::LooseCachePath(const VfsPath& sourcePath, const MD5& initialHash, u32 version)
    118118{
    119     FileInfo fileInfo;
     119    CFileInfo fileInfo;
    120120    if (m_VFS->GetFileInfo(sourcePath, &fileInfo) < 0)
    121121    {
    122122        debug_warn(L"source file disappeared"); // this should never happen
  • source/ps/SavedGame.cpp

     
    8787    archiveWriter.reset(); // close the file
    8888
    8989    WriteBuffer buffer;
    90     FileInfo tempSaveFile;
     90    CFileInfo tempSaveFile;
    9191    WARN_RETURN_STATUS_IF_ERR(GetFileInfo(tempSaveFileRealPath, &tempSaveFile));
    9292    buffer.Reserve(tempSaveFile.Size());
    9393    WARN_RETURN_STATUS_IF_ERR(io::Load(tempSaveFileRealPath, buffer.Data().get(), buffer.Size()));
     
    112112    {
    113113    }
    114114
    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)
    116116    {
    117117        ((CGameLoader*)cbData)->ReadEntry(pathname, fileInfo, archiveFile);
    118118    }
    119119
    120     void ReadEntry(const VfsPath& pathname, const FileInfo& fileInfo, PIArchiveFile archiveFile)
     120    void ReadEntry(const VfsPath& pathname, const CFileInfo& fileInfo, PIArchiveFile archiveFile)
    121121    {
    122122        if (pathname == L"metadata.json" && m_Metadata)
    123123        {
  • source/ps/scripting/JSInterface_VFS.cpp

     
    6666};
    6767
    6868// 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)
     69static Status BuildDirEntListCB(const VfsPath& pathname, const CFileInfo& UNUSED(fileINfo), uintptr_t cbData)
    7070{
    7171    BuildDirEntListState* s = (BuildDirEntListState*)cbData;
    7272
     
    140140    if (!ToPrimitive<CStrW> (cx, JS_ARGV(cx, vp)[0], filename))
    141141        return JS_FALSE;
    142142
    143     FileInfo fileInfo;
     143    CFileInfo fileInfo;
    144144    Status err = g_VFS->GetFileInfo(filename, &fileInfo);
    145145    JS_CHECK_FILE_ERR(err);
    146146
     
    161161    if (!ToPrimitive<CStrW> (cx, JS_ARGV(cx, vp)[0], filename))
    162162        return JS_FALSE;
    163163
    164     FileInfo fileInfo;
     164    CFileInfo fileInfo;
    165165    Status err = g_VFS->GetFileInfo(filename, &fileInfo);
    166166    JS_CHECK_FILE_ERR(err);
    167167
  • source/scriptinterface/DebuggingServer.cpp

     
    176176}
    177177
    178178
    179 static Status AddFileResponse(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)
     179static Status AddFileResponse(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData)
    180180{
    181181    std::vector<std::string>& templates = *(std::vector<std::string>*)cbData;
    182182    std::wstring str(pathname.string());
  • source/simulation2/components/CCmpTemplateManager.cpp

     
    429429    CParamNode::LoadXMLString(out, xml.c_str(), actorNameW.c_str());
    430430}
    431431
    432 static Status AddToTemplates(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)
     432static Status AddToTemplates(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData)
    433433{
    434434    std::vector<std::string>& templates = *(std::vector<std::string>*)cbData;
    435435
     
    446446    return INFO::OK;
    447447}
    448448
    449 static Status AddActorToTemplates(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)
     449static Status AddActorToTemplates(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData)
    450450{
    451451    std::vector<std::string>& templates = *(std::vector<std::string>*)cbData;
    452452
  • source/simulation2/components/ICmpAIManager.cpp

     
    4747        vfs::ForEachFile(g_VFS, L"simulation/ai/", Callback, (uintptr_t)this, L"*.json", vfs::DIR_RECURSIVE);
    4848    }
    4949
    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)
    5151    {
    5252        GetAIsHelper* self = (GetAIsHelper*)cbData;
    5353
  • source/simulation2/system/ComponentManager.cpp

     
    961961    return componentManager->GetScriptInterface().ReadJSONFile(path).get();
    962962}
    963963   
    964 Status CComponentManager::FindJSONFilesCallback(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)
     964Status CComponentManager::FindJSONFilesCallback(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData)
    965965{
    966966    FindJSONFilesCallbackData* data = (FindJSONFilesCallbackData*)cbData;
    967967   
  • source/simulation2/system/ComponentManager.h

     
    245245    static CScriptVal ReadJSONFile(void *cbdata, std::wstring filePath, std::wstring fileName);
    246246   
    247247    // 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);
    249249
    250250    CMessage* ConstructMessage(int mtid, CScriptVal data);
    251251    void SendGlobalMessage(entity_id_t ent, const CMessage& msg) const;
  • source/soundmanager/SoundManager.cpp

     
    2020#include "ISoundManager.h"
    2121#include "SoundManager.h"
    2222
     23#include "ps/Filesystem.h"
     24
    2325#include "soundmanager/data/SoundData.h"
    2426#include "soundmanager/items/CSoundItem.h"
    2527#include "soundmanager/items/CBufferItem.h"
     
    235237        al_ReportError(err, caller, line);
    236238}
    237239
     240Status 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
    238251CSoundManager::CSoundManager()
    239252{
    240253    m_CurrentEnvirons   = 0;
     
    277290        m_Worker = new CSoundManagerWorker();
    278291        m_Worker->SetEnabled( true );
    279292    }
     293
     294    RegisterFileReloadFunc(ReloadChangedFileCB, this);
    280295}
    281296
    282297CSoundManager::~CSoundManager()
    283298{
     299    UnregisterFileReloadFunc(ReloadChangedFileCB, this);
     300
    284301    if (m_Worker )
    285302    {
    286303        AL_CHECK
  • source/soundmanager/SoundManager.h

     
    102102    ISoundItem* ItemForData(CSoundData* itemData);
    103103    ISoundItem* ItemForEntity( entity_id_t source, CSoundData* sndData);
    104104
     105    Status ReloadChangedFiles(const VfsPath& path);
     106
    105107    void ClearPlayListItems();
    106108    void StartPlayList( bool doLoop );
    107109    void AddPlayListItem( const VfsPath* itemPath);
     
    109111    static void ScriptingInit();
    110112    static void CreateSoundManager();
    111113    static void SetEnabled(bool doEnable);
    112    
     114    static Status ReloadChangedFileCB(void* param, const VfsPath& path);
     115
    113116    static void al_ReportError(ALenum err, const char* caller, int line);
    114117    static void al_check(const char* caller, int line);
    115118