-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8241505
Showing
9 changed files
with
1,118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
/imobax |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
VERSION = 1.0.0 | ||
TARGET = imobax | ||
SRCDIR = src | ||
FLAGS ?= -Wall -O3 -DVERSION=$(VERSION) -DTIMESTAMP="`date +'%d. %B %Y %H:%M:%S'`" -flto -lsqlite3 $(CFLAGS) | ||
|
||
.PHONY: all clean | ||
|
||
all: $(TARGET) | ||
|
||
$(TARGET): $(SRCDIR)/*.c | ||
$(CC) -o $@ $^ $(FLAGS) | ||
|
||
clean: | ||
rm -f $(TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# imobax | ||
|
||
The **i**OS **Mo**bile **Ba**ckup **X**tractor. | ||
It extracts backups... and stuff. | ||
|
||
Binary releases for macOS: [here](https://github.com/Siguza/imobax/releases). | ||
|
||
### Building | ||
|
||
As always: | ||
|
||
make | ||
|
||
### Usage | ||
|
||
Usage: | ||
./imobax [-f] [-i] [-l] source-dir [target-dir] | ||
|
||
Options: | ||
-f Force overwriting of existing files | ||
-i Ignore missing files in backup | ||
-l List contents only, write nothing | ||
|
||
### License | ||
|
||
[MPL2](https://github.com/Siguza/imobax/blob/master/LICENSE) with Exhibit B. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* Copyright (c) 2019 Siguza | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* This Source Code Form is "Incompatible With Secondary Licenses", as | ||
* defined by the Mozilla Public License, v. 2.0. | ||
**/ | ||
|
||
#include <errno.h> | ||
#include <stdbool.h> | ||
#include <stdlib.h> // free | ||
#include <string.h> // strdup | ||
#include <unistd.h> // faccessat, F_OK | ||
#include <sys/stat.h> // mkdirat | ||
|
||
#include "common.h" | ||
|
||
int mkdirat_recursive(int fd, const char *path, bool only_parent) | ||
{ | ||
int retval = -1; | ||
char *str = NULL; | ||
|
||
if(path[0] == '\0') | ||
{ | ||
LOG("mkdirat_recursive: bad argument"); | ||
goto out; | ||
} | ||
|
||
str = strdup(path); | ||
if(!str) | ||
{ | ||
ERRNO("strdup(%s)", path); | ||
goto out; | ||
} | ||
|
||
for(size_t i = 1; 1; ++i) | ||
{ | ||
bool doit = false, | ||
flip = false, | ||
end = false; | ||
if(str[i] == '/') | ||
{ | ||
doit = true; | ||
flip = true; | ||
} | ||
else if(str[i] == '\0') | ||
{ | ||
if(!only_parent) | ||
{ | ||
doit = true; | ||
} | ||
end = true; | ||
} | ||
|
||
if(doit) | ||
{ | ||
if(flip) | ||
{ | ||
str[i] = '\0'; | ||
} | ||
|
||
if(faccessat(fd, str, F_OK, 0) != 0) | ||
{ | ||
if(errno != ENOENT) | ||
{ | ||
ERRNO("access(%s)", str); | ||
break; | ||
} | ||
else | ||
{ | ||
if(mkdirat(fd, str, 0755) != 0) | ||
{ | ||
ERRNO("mkdir(%s)", str); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if(flip) | ||
{ | ||
str[i] = '/'; | ||
} | ||
} | ||
|
||
if(end) | ||
{ | ||
break; | ||
} | ||
} | ||
|
||
retval = 0; | ||
out:; | ||
if(str) free(str); | ||
return retval; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Copyright (c) 2019 Siguza | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* This Source Code Form is "Incompatible With Secondary Licenses", as | ||
* defined by the Mozilla Public License, v. 2.0. | ||
**/ | ||
|
||
#ifndef COMMON_H | ||
#define COMMON_H | ||
|
||
#include <errno.h> | ||
#include <stdbool.h> | ||
#include <stdio.h> // fprintf, stderr | ||
#include <string.h> // strerror | ||
|
||
#define LOG(str, args...) do { fprintf(stderr, str "\n", ##args); } while(0) | ||
#define ERRNO(str, args...) LOG(str ": %s", ##args, strerror(errno)) | ||
|
||
#define STRINGIFX(x) #x | ||
#define STRINGIFY(x) STRINGIFX(x) | ||
|
||
int mkdirat_recursive(int fd, const char *path, bool only_parent); | ||
|
||
#endif |
Oops, something went wrong.