summaryrefslogtreecommitdiffstats
path: root/hcid/storage.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-08-30 00:35:39 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-08-30 00:35:39 +0000
commit44385c0baa98b0e27dad39cb8bd0e33ce5a027f6 (patch)
treee216d9746db798291f00dade69b46f33fdf2ff45 /hcid/storage.c
parent3882b4e761ed1411406e375ec1b4b0790509939e (diff)
Move create_dirs() and create_file() into the textfile library
Diffstat (limited to 'hcid/storage.c')
-rw-r--r--hcid/storage.c50
1 files changed, 0 insertions, 50 deletions
diff --git a/hcid/storage.c b/hcid/storage.c
index eed3e694..e270cbd8 100644
--- a/hcid/storage.c
+++ b/hcid/storage.c
@@ -48,56 +48,6 @@
#include "textfile.h"
#include "hcid.h"
-static int create_dirs(char *filename, mode_t mode)
-{
- struct stat st;
- char dir[PATH_MAX + 1], *prev, *next;
- int err;
-
- err = stat(filename, &st);
- if (!err && S_ISREG(st.st_mode))
- return 0;
-
- memset(dir, 0, PATH_MAX + 1);
- strcat(dir, "/");
-
- prev = strchr(filename, '/');
-
- while (prev) {
- next = strchr(prev + 1, '/');
- if (!next)
- break;
-
- if (next - prev == 1) {
- prev = next;
- continue;
- }
-
- strncat(dir, prev + 1, next - prev);
- mkdir(dir, mode);
-
- prev = next;
- }
-
- return 0;
-}
-
-static inline int create_file(char *filename, mode_t mode)
-{
- int fd;
-
- umask(S_IWGRP | S_IWOTH);
- create_dirs(filename, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
-
- fd = open(filename, O_RDWR | O_CREAT, mode);
- if (fd < 0)
- return fd;
-
- close(fd);
-
- return 0;
-}
-
int write_device_name(bdaddr_t *local, bdaddr_t *peer, char *name)
{
char filename[PATH_MAX + 1], addr[18], str[249];