forked from cory/tildefriends
Add a little app to list apps.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3712 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -273,6 +273,7 @@ static int _tf_command_export(const char* file, int argc, char* argv[])
|
||||
else
|
||||
{
|
||||
const char* k_export[] = {
|
||||
"/~cory/apps",
|
||||
"/~cory/index",
|
||||
"/~cory/docs",
|
||||
};
|
||||
|
@ -22,6 +22,14 @@ static void _write_file(const char* path, void* blob, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
static void _make_dir(const char* path)
|
||||
{
|
||||
if (mkdir(path, 0755) && errno != EEXIST)
|
||||
{
|
||||
printf("Failed to create directory %s: %s.\n", path, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
void tf_ssb_export(tf_ssb_t* ssb, const char* key)
|
||||
{
|
||||
char user[256] = { 0 };
|
||||
@ -66,6 +74,11 @@ void tf_ssb_export(tf_ssb_t* ssb, const char* key)
|
||||
return;
|
||||
}
|
||||
char file_path[1024];
|
||||
_make_dir("apps/");
|
||||
snprintf(file_path, sizeof(file_path), "apps/%s", user);
|
||||
_make_dir(file_path);
|
||||
snprintf(file_path, sizeof(file_path), "apps/%s/%s", user, path);
|
||||
_make_dir(file_path);
|
||||
snprintf(file_path, sizeof(file_path), "apps/%s/%s.json", user, path);
|
||||
_write_file(file_path, blob, size);
|
||||
JSContext* context = tf_ssb_get_context(ssb);
|
||||
|
Reference in New Issue
Block a user