Ticket #514: next_mac_wdir.patch

File next_mac_wdir.patch, 33.1 KB (added by stwf, 11 years ago)

newest version of patch to add mac file notifications

  • 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
  • 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_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
     41struct DirWatch
    2942{
     43  OsPath path;
     44  int reqnum;
     45};
     46
     47typedef std::vector<DirWatch> DirWatchMap;
     48static DirWatchMap g_Paths;
     49static DirWatchMap g_RootPaths;
     50static DirWatchNotifications g_QueuedDirs;
     51
     52bool  CanRunNotifications()
     53{
     54  int major = 0;
     55  int minor = 0;   
     56  int bugfix = 0;   
     57
     58  GetSystemVersion( major, minor, bugfix);
     59
     60  if ((major == 10 && minor >= 7) || major >= 11)
     61    return true;
     62
     63  return false;
     64}
     65
     66#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
     67  #define FlagFileEventsSubstitute kFSEventStreamCreateFlagFileEvents
     68#else
     69  #define FlagFileEventsSubstitute  0x00000010
     70#endif
     71
     72static void fsevent_callback(
     73    ConstFSEventStreamRef UNUSED(streamRef),
     74    void * UNUSED(clientCallBackInfo),
     75    size_t numEvents,
     76    void *eventPaths,
     77    const FSEventStreamEventFlags eventFlags[],
     78    const FSEventStreamEventId UNUSED(eventIds)[] )
     79{
     80    unsigned long i;
     81    char **paths = (char **)eventPaths;
     82 
     83    for (i=0; i<numEvents; i++)
     84    {
     85      bool    isWatched = false;
     86      OsPath eventPath  = OsPath(paths[i]);
     87      unsigned long eventType = eventFlags[i];
     88
     89      if ( eventPath.Filename().string().c_str()[0] != '.' )
     90      {
     91        for ( DirWatchMap::iterator it = g_Paths.begin() ; it != g_Paths.end(); ++it)
     92          if ( path_is_subpath( it->path.string().c_str(), eventPath.string().c_str() ) )
     93            isWatched = true;
     94      }
     95
     96      if ( ! isWatched )
     97        return;
     98
     99      OsPath filename = Path( eventPath.string().c_str() );
     100
     101      if ( eventType & kFSEventStreamEventFlagItemIsFile)
     102      {
     103        if ( eventType & kFSEventStreamEventFlagItemRemoved )
     104          g_QueuedDirs.push_back(DirWatchNotification( filename.string().c_str(), DirWatchNotification::Deleted ));
     105        else if ( eventType & kFSEventStreamEventFlagItemRenamed )
     106          g_QueuedDirs.push_back(DirWatchNotification( filename.string().c_str(), DirWatchNotification::Deleted ));
     107        else if ( eventType & kFSEventStreamEventFlagItemCreated )
     108          g_QueuedDirs.push_back(DirWatchNotification( filename.string().c_str(), DirWatchNotification::Created ));
     109        else if ( eventType & kFSEventStreamEventFlagItemModified )
     110          g_QueuedDirs.push_back(DirWatchNotification( filename.string().c_str(), DirWatchNotification::Changed ));
     111        else
     112          LOGERROR( L"unknown event captured %ls and flags%ld\n", filename.string().c_str(), eventType);
     113      }
     114    }
     115
     116}
     117
     118FSEventStreamRef CreateEventStream( DirWatchMap path )
     119{
     120  if ( ( g_Stream == NULL ) && CanRunNotifications() )
     121  {
     122    CFStringRef* pathLists = (CFStringRef*)malloc( sizeof(CFStringRef*) * path.size() );
     123    int   index = 0;
     124    for ( DirWatchMap::iterator it = path.begin() ; it != path.end(); ++it)
     125    {
     126      pathLists[index] = CFStringCreateWithFileSystemRepresentation( NULL, OsString(it->path).c_str());
     127      index++;
     128    }
     129    CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)pathLists, index, NULL);
     130
     131    FSEventStreamContext *callbackInfo = NULL;
     132 
     133    FSEventStreamRef stream = FSEventStreamCreate(NULL, &fsevent_callback, callbackInfo, pathsToWatch,
     134        kFSEventStreamEventIdSinceNow, 1.0, FlagFileEventsSubstitute );
     135
     136    CFRelease( pathsToWatch );
     137    free( pathLists );
     138
     139    FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
     140    if (!FSEventStreamStart(stream))
     141      debug_warn(L"event_loop FSEventStreamStart failed!");
     142    else
     143      return stream;
     144  }
     145  return NULL;
     146}
     147
     148void DeleteEventStream()
     149{
     150  if ( g_Stream != NULL )
     151  {
     152    FSEventStreamStop(g_Stream);
     153    FSEventStreamInvalidate(g_Stream);
     154    FSEventStreamRelease(g_Stream);
     155
     156    g_Stream = NULL;
     157  }
     158}
     159
     160
     161Status dir_watch_Add(const OsPath& path, PDirWatch& dirWatch)
     162{
     163  PDirWatch tmpDirWatch(new DirWatch);
     164  dirWatch.swap(tmpDirWatch);
     165  dirWatch->path = path;
     166  dirWatch->reqnum = 0;
     167  g_Paths.push_back( *dirWatch );
     168
     169  bool  alreadyInsideRootPath = false;
     170  for ( DirWatchMap::iterator it = g_RootPaths.begin() ; it != g_RootPaths.end(); ++it)
     171  {
     172    if ( path_is_subpath( path.string().c_str(), it->path.string().c_str() ) )
     173      alreadyInsideRootPath = true;
     174  }
     175
     176  if ( !alreadyInsideRootPath )
     177  {
     178    DeleteEventStream();
     179    g_RootPaths.push_back( *dirWatch );
     180  }
     181
    30182    return INFO::OK;
    31183}
    32184
    33 Status dir_watch_Poll(DirWatchNotifications& UNUSED(notifications))
     185Status dir_watch_Poll(DirWatchNotifications& notifications)
    34186{
     187  if ( g_Stream == NULL )
     188  {
     189    g_Stream = CreateEventStream( g_RootPaths );   
     190  }
     191  else
     192  {
     193    for ( DirWatchNotifications::iterator it = g_QueuedDirs.begin() ; it != g_QueuedDirs.end(); ++it)
     194      notifications.push_back(DirWatchNotification( *it ));
     195
     196    g_QueuedDirs.clear();
     197  }
     198
    35199    return INFO::OK;
    36200}
  • 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"
     
    208210
    209211void ISoundManager::CreateSoundManager()
    210212{
    211     g_SoundManager = new CSoundManager();
     213    if ( !g_SoundManager )
     214        g_SoundManager = new CSoundManager();
    212215}
    213216
    214217void ISoundManager::SetEnabled(bool doEnable)
     
    217220    {
    218221        SAFE_DELETE(g_SoundManager);
    219222    }
    220     else if ( ! g_SoundManager && doEnable )
     223    else if ( !g_SoundManager && doEnable )
    221224    {
    222225        ISoundManager::CreateSoundManager();
    223226    }
     
    235238        al_ReportError(err, caller, line);
    236239}
    237240
     241Status CSoundManager::ReloadChangedFiles(const VfsPath& UNUSED(path))
     242{
     243//  LOGERROR(L"GUI file '%ls' changed - reloading page", path.string().c_str());
     244
     245    return INFO::OK;
     246}
     247
     248/*static*/ Status CSoundManager::ReloadChangedFileCB(void* param, const VfsPath& path)
     249{
     250    return static_cast<CSoundManager*>(param)->ReloadChangedFiles(path);
     251}
     252
    238253CSoundManager::CSoundManager()
    239254{
    240255    m_CurrentEnvirons   = 0;
     
    277292        m_Worker = new CSoundManagerWorker();
    278293        m_Worker->SetEnabled( true );
    279294    }
     295
     296    RegisterFileReloadFunc(ReloadChangedFileCB, this);
    280297}
    281298
    282299CSoundManager::~CSoundManager()
    283300{
     301    UnregisterFileReloadFunc(ReloadChangedFileCB, this);
     302
    284303    if (m_Worker )
    285304    {
    286305        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