Skip to content

Commit 5d2143d

Browse files
audcore: Create cache subdir if necessary
The "audacious" subdirectory may not exist yet. Regression from commit cae0d90.
1 parent 4e3449d commit 5d2143d

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/libaudcore/util.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
#include "audstrings.h"
3333
#include "runtime.h"
3434

35+
#ifdef S_IRGRP
36+
#define DIRMODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
37+
#else
38+
#define DIRMODE (S_IRWXU)
39+
#endif
40+
3541
const char * get_home_utf8()
3642
{
3743
static std::once_flag once;
@@ -65,7 +71,14 @@ bool dir_foreach(const char * path, DirForeachFunc func, void * user)
6571

6672
String write_temp_file(const void * data, int64_t len)
6773
{
68-
StringBuf name = filename_build({g_get_user_cache_dir(), PACKAGE, "temp-XXXXXX"});
74+
StringBuf dir = filename_build({g_get_user_cache_dir(), PACKAGE});
75+
if (g_mkdir_with_parents(dir, DIRMODE) < 0)
76+
{
77+
AUDERR("Error creating temporary directory: %s\n", strerror(errno));
78+
return String();
79+
}
80+
81+
StringBuf name = filename_build({dir, "temp-XXXXXX"});
6982

7083
int handle = g_mkstemp(name);
7184
if (handle < 0)

0 commit comments

Comments
 (0)