cinera.c: Let inotify monitor IN_MOVED_TO events

It seems that rsync triggers these events, so we must handle these in
addition to the IN_CLOSE_WRITE ones triggered by re-saves.

Also fix MakeDir() to correctly make parent directories (i.e. mkdir -p).
This commit is contained in:
Matt Mascarenhas 2018-10-05 20:57:09 +01:00
parent c4ef54c742
commit d37a39af32
1 changed files with 5 additions and 5 deletions

View File

@ -17,7 +17,7 @@ typedef struct
version CINERA_APP_VERSION = { version CINERA_APP_VERSION = {
.Major = 0, .Major = 0,
.Minor = 6, .Minor = 6,
.Patch = 3 .Patch = 4
}; };
#include <stdarg.h> // NOTE(matt): varargs #include <stdarg.h> // NOTE(matt): varargs
@ -1270,7 +1270,6 @@ int
MakeDir(char *Path) MakeDir(char *Path)
{ {
// TODO(matt): Correctly check for permissions // TODO(matt): Correctly check for permissions
int i = StringLength(Path);
int Ancestors = 0; int Ancestors = 0;
while(mkdir(Path, 00755) == -1) while(mkdir(Path, 00755) == -1)
{ {
@ -1281,6 +1280,7 @@ MakeDir(char *Path)
if(StripComponentFromPath(Path) == RC_ERROR_DIRECTORY) { return RC_ERROR_DIRECTORY; } if(StripComponentFromPath(Path) == RC_ERROR_DIRECTORY) { return RC_ERROR_DIRECTORY; }
++Ancestors; ++Ancestors;
} }
int i = StringLength(Path);
while(Ancestors > 0) while(Ancestors > 0)
{ {
while(Path[i] != '\0') while(Path[i] != '\0')
@ -2108,7 +2108,7 @@ PushHMMLWatchHandle(void)
{ {
FitWatchHandle(); FitWatchHandle();
CopyString(WatchHandles.Handle[WatchHandles.Count].Path, sizeof(WatchHandles.Handle[0].Path), Config.ProjectDir); CopyString(WatchHandles.Handle[WatchHandles.Count].Path, sizeof(WatchHandles.Handle[0].Path), Config.ProjectDir);
WatchHandles.Handle[WatchHandles.Count].Descriptor = inotify_add_watch(inotifyInstance, Config.ProjectDir, IN_CLOSE_WRITE | IN_DELETE); WatchHandles.Handle[WatchHandles.Count].Descriptor = inotify_add_watch(inotifyInstance, Config.ProjectDir, IN_MOVED_TO | IN_CLOSE_WRITE | IN_DELETE);
WatchHandles.Handle[WatchHandles.Count].Type = WT_HMML; WatchHandles.Handle[WatchHandles.Count].Type = WT_HMML;
++WatchHandles.Count; ++WatchHandles.Count;
} }
@ -7991,7 +7991,7 @@ MonitorFilesystem(buffers *CollationBuffers, template *SearchTemplate, template
{ {
Deleted |= (DeleteEntry(&Neighbourhood, Event->name) == RC_SUCCESS); Deleted |= (DeleteEntry(&Neighbourhood, Event->name) == RC_SUCCESS);
} }
else if(Event->mask & IN_CLOSE_WRITE) else if(Event->mask & IN_CLOSE_WRITE || Event->mask & IN_MOVED_TO)
{ {
Inserted |= (InsertEntry(&Neighbourhood, CollationBuffers, PlayerTemplate, BespokeTemplate, Event->name, 0) == RC_SUCCESS); Inserted |= (InsertEntry(&Neighbourhood, CollationBuffers, PlayerTemplate, BespokeTemplate, Event->name, 0) == RC_SUCCESS);
} }
@ -9064,7 +9064,7 @@ main(int ArgC, char **Args)
goto RIP; goto RIP;
} }
printf("\n┌╼ Monitoring Annotations Directory for %snew%s, %sedited%s and %sdeleted%s .hmml files ╾┐\n", printf("\n┌╼ Monitoring file system for %snew%s, %sedited%s and %sdeleted%s .hmml and asset files ╾┐\n",
ColourStrings[EditTypes[EDIT_ADDITION].Colour], ColourStrings[CS_END], ColourStrings[EditTypes[EDIT_ADDITION].Colour], ColourStrings[CS_END],
ColourStrings[EditTypes[EDIT_REINSERTION].Colour], ColourStrings[CS_END], ColourStrings[EditTypes[EDIT_REINSERTION].Colour], ColourStrings[CS_END],
ColourStrings[EditTypes[EDIT_DELETION].Colour], ColourStrings[CS_END]); ColourStrings[EditTypes[EDIT_DELETION].Colour], ColourStrings[CS_END]);