import "System"
+#if !defined(__EMSCRIPTEN__)
+
public class FileChange
{
public:
public:
property void * userData { set { data = value; } };
property FileChange fileChange { set { watchFor = value; } };
- property char * fileName
+ property const char * fileName
{
set
{
}
get { return fileName; }
};
- property char * directoryName
+ property const char * directoryName
{
set
{
TimeStamp modified;
FileSize size;
FileAttribs attribs;
- virtual bool any_object::OnDirNotify(FileChange action, char * fileName, char * param);
+ public virtual bool any_object::OnDirNotify(FileChange action, const char * fileName, const char * param);
// For directory monitors
bool directory;
OldList files;
- virtual bool any_object::OnFileNotify(FileChange action, char * param);
+ public virtual bool any_object::OnFileNotify(FileChange action, const char * param);
/*
#if defined(__WIN32__)
globalSystem.fileMonitorMutex.Release();
}
- void MonitorFile(char * filePath)
+ void MonitorFile(const char * filePath)
{
FileAttribs exists = FileExists(filePath);
FileStats stats;
+ String oldFileName = fileName;
//incref this;
globalSystem.fileMonitorMutex.Wait();
if(!active && !toBeFreed)
globalSystem.fileMonitors.Add(this);
this.exists = exists && !exists.isDirectory;
- delete fileName;
fileName = CopyString(filePath);
+ delete oldFileName;
this.watchFor = watchFor;
if(FileGetStats(filePath, stats))
}
}
- void MonitorDirectory(char * filePath)
+ void MonitorDirectory(const char * filePath)
{
FileStats stats;
+ String oldFileName = fileName;
//incref this;
globalSystem.fileMonitorMutex.Wait();
exists = FileExists(filePath).isDirectory;
this.watchFor = watchFor;
- delete fileName;
fileName = CopyString(filePath);
+ delete oldFileName;
if(FileGetStats(fileName, stats))
{
// delete this;
}
- bool AddFileNotify(FileChange action, char * fileName, char * param)
+ bool AddFileNotify(FileChange action, const char * fileName, const char * param)
{
if(watchFor & action)
{
- fileNotifies.Add(FileNotify {
+ fileNotifies.Add(FileNotify {
monitor = this, action = action, fileName = CopyString(fileName), param = CopyString(param)
});
return true;
return 1;
else if(e1.attribs.isDirectory && !e2.attribs.isDirectory)
return -1;
- else
+ else
return strcmp(e1.name, e2.name);
}
-static void GetFileEntries(OldList list, char * path)
+static void GetFileEntries(OldList list, const char * path)
{
FileListing listing { path, null };
while(listing.Find())
bool fileActivity = false;
lastTime = currentTime;
- // printf("[%d] Waiting in MonitorThread for fileMonitor Mutex %x...\n", GetCurrentThreadID(), globalSystem.fileMonitorMutex);
+ // printf("[%d] Waiting in MonitorThread for fileMonitor Mutex %x...\n", (int)GetCurrentThreadID(), globalSystem.fileMonitorMutex);
globalSystem.fileMonitorMutex.Wait();
for(monitor = globalSystem.fileMonitors.first; monitor; monitor = monitor.next)
}
monitor.files.Free(FileEntry::Free);
monitor.files = newEntries;
- }
+ }
}
else if(monitor.fileName)
{
{
fileActivity |= monitor.AddFileNotify(FileChange { deleted = true }, monitor.fileName, null);
monitor.exists = false;
- }
+ }
else if(monitor.exists)
{
FileStats stats { };
}
if(fileActivity)
{
- // printf("[%d] Signaling Event...\n", GetCurrentThreadID());
+ // printf("[%d] Signaling Event...\n", (int)GetCurrentThreadID());
guiApp.SignalEvent();
}
- // printf("[%d] Releasing Mutex...\n", GetCurrentThreadID());
+ // printf("[%d] Releasing Mutex...\n", (int)GetCurrentThreadID());
globalSystem.fileMonitorMutex.Release();
}
-
- // printf("[%d] Sleeping...\n", GetCurrentThreadID());
+
+ // printf("[%d] Sleeping...\n", (int)GetCurrentThreadID());
Sleep(1.0 / 18.2);
}
return 0;
}
}
+
+#endif // !defined(__EMSCRIPTEN__)