Commit e4c14462 authored by Matt Mascarenhas's avatar Matt Mascarenhas

cinera.c: Call MakeDir() in GenerateTopicColours()

parent 120290b3
......@@ -14,9 +14,10 @@ typedef struct
version CINERA_APP_VERSION = {
.Major = 0,
.Minor = 5,
.Patch = 13
.Patch = 14
};
// TODO(matt): Copy in the DB 3 stuff from cinera_working.c
#define CINERA_DB_VERSION 2
#define DEBUG 0
......@@ -1600,6 +1601,25 @@ GenerateTopicColours(char *Topic)
CopyString(Topics.Path, "%s/cinera_topics.css", Config.RootDir);
}
char *Ptr = Topics.Path + StringLength(Topics.Path) - 1;
while(*Ptr != '/')
{
--Ptr;
}
*Ptr = '\0';
DIR *CSSDirHandle; // TODO(matt): open()
if(!(CSSDirHandle = opendir(Topics.Path)))
{
if(MakeDir(Topics.Path) == RC_ERROR_DIRECTORY)
{
LogError(LOG_ERROR, "Unable to create directory %s: %s", Topics.Path, strerror(errno));
fprintf(stderr, "Unable to create directory %s: %s\n", Topics.Path, strerror(errno));
return RC_ERROR_DIRECTORY;
};
}
closedir(CSSDirHandle);
*Ptr = '/';
if((Topics.Handle = fopen(Topics.Path, "a+")))
{
fseek(Topics.Handle, 0, SEEK_END);
......@@ -1649,6 +1669,8 @@ GenerateTopicColours(char *Topic)
}
else
{
// NOTE(matt): Maybe it shouldn't be possible to hit this case now that we MakeDir the actually dir...
perror(Topics.Path);
return RC_ERROR_FILE;
}
}
......@@ -1664,6 +1686,7 @@ PrintUsage(char *BinaryLocation, config *DefaultConfig)
" Override default root directory (\"%s\")\n"
" -R <root URL>\n"
" Override default root URL (\"%s\")\n"
" \e[1;31mIMPORTANT\e[0m: -r and -R must correspond to the same location\n"
" -c <CSS directory path>\n"
" Override default CSS directory (\"%s\"), relative to root\n"
" -i <images directory path>\n"
......@@ -4165,9 +4188,9 @@ MonitorDirectory(buffers *CollationBuffers, template *IndexTemplate, template *P
fclose(MemLog);
#endif
// TODO(matt): Maybe straight up store the IndexPath in the Config to save us having to derive it near / at the usage site
buffer Events;
if(ClaimBuffer(&Events, "inotify Events", Kilobytes(32)) == RC_ARENA_FULL) { return RC_ARENA_FULL; };
// TODO(matt): Figure out the max size necessary for the Events buffer
if(ClaimBuffer(&Events, "inotify Events", Kilobytes(1024)) == RC_ARENA_FULL) { return RC_ARENA_FULL; };
struct inotify_event *Event;
int BytesRead;
......@@ -4860,6 +4883,7 @@ main(int ArgC, char **Args)
}
NextFile:
// TODO(matt): Just change the default output location so all these guys won't overwrite each other
for(int FileIndex = optind; FileIndex < ArgC; ++FileIndex)
{
switch(HMMLToBuffers(&CollationBuffers, Args[FileIndex]))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment