Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jean-Baptiste Kempf
libaacs
Commits
cf9c985b
Commit
cf9c985b
authored
May 06, 2015
by
npzacs
Browse files
Move system-dependent code to own file
parent
da8a5fb8
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/file/dirs.h
View file @
cf9c985b
...
...
@@ -22,10 +22,6 @@
#include "util/attributes.h"
#ifdef _WIN32
BD_PRIVATE
int
win32_mkdir
(
const
char
*
dir
);
#endif
/*
* Config, cache and data dirs
*/
...
...
src/file/dirs_win32.c
View file @
cf9c985b
...
...
@@ -34,14 +34,6 @@
#include <direct.h>
int
win32_mkdir
(
const
char
*
dir
)
{
wchar_t
wdir
[
MAX_PATH
];
MultiByteToWideChar
(
CP_UTF8
,
0
,
dir
,
-
1
,
wdir
,
MAX_PATH
);
return
_wmkdir
(
wdir
);
}
char
*
file_get_config_home
(
void
)
{
return
file_get_data_home
();
...
...
src/file/file.h
View file @
cf9c985b
...
...
@@ -46,5 +46,10 @@
BD_PRIVATE
extern
AACS_FILE_H
*
(
*
file_open
)(
const
char
*
filename
,
const
char
*
mode
);
/*
* local filesystem
*/
BD_PRIVATE
int
file_mkdir
(
const
char
*
dir
);
#endif
/* FILE_H_ */
src/file/file_posix.c
View file @
cf9c985b
...
...
@@ -29,6 +29,9 @@
#include <inttypes.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
static
void
file_close_linux
(
AACS_FILE_H
*
file
)
{
if
(
file
)
{
...
...
@@ -85,3 +88,8 @@ static AACS_FILE_H *file_open_linux(const char* filename, const char *mode)
}
AACS_FILE_H
*
(
*
file_open
)(
const
char
*
filename
,
const
char
*
mode
)
=
file_open_linux
;
int
file_mkdir
(
const
char
*
dir
)
{
return
mkdir
(
dir
,
S_IRWXU
);
}
src/file/file_win32.c
View file @
cf9c985b
...
...
@@ -112,3 +112,13 @@ static AACS_FILE_H *_file_open(const char* filename, const char *mode)
}
AACS_FILE_H
*
(
*
file_open
)(
const
char
*
filename
,
const
char
*
mode
)
=
_file_open
;
int
file_mkdir
(
const
char
*
dir
)
{
wchar_t
wdir
[
MAX_PATH
];
MultiByteToWideChar
(
CP_UTF8
,
0
,
dir
,
-
1
,
wdir
,
MAX_PATH
);
if
(
!
CreateDirectoryW
(
wdir
,
NULL
))
return
-
1
;
return
0
;
}
src/file/keydbcfg.c
View file @
cf9c985b
...
...
@@ -20,6 +20,7 @@
#include "keydbcfg.h"
#include "dirs.h"
#include "file.h"
#include "util/strutl.h"
#include "util/logging.h"
...
...
@@ -31,15 +32,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _WIN32
# define mkdir(p,m) win32_mkdir(p)
# define DIR_SEP_CHAR '\\'
# define DIR_SEP "\\"
#else
# define DIR_SEP_CHAR '/'
# define DIR_SEP "/"
#endif
#define CFG_DIR "aacs"
...
...
@@ -73,7 +65,7 @@ static int _mkpath(const char *path)
if
(
stat
(
dir
,
&
s
)
!=
0
||
!
S_ISDIR
(
s
.
st_mode
))
{
BD_DEBUG
(
DBG_FILE
,
"Creating directory %s
\n
"
,
dir
);
if
(
mkdir
(
dir
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
)
==
-
1
)
{
if
(
file_
mkdir
(
dir
)
==
-
1
)
{
BD_DEBUG
(
DBG_FILE
|
DBG_CRIT
,
"Error creating directory %s
\n
"
,
dir
);
result
=
0
;
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment