aboutsummaryrefslogtreecommitdiff
path: root/imagesortc.c
diff options
context:
space:
mode:
Diffstat (limited to 'imagesortc.c')
-rw-r--r--imagesortc.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/imagesortc.c b/imagesortc.c
index 00e6407..f699e98 100644
--- a/imagesortc.c
+++ b/imagesortc.c
@@ -154,9 +154,14 @@ int main(int argc, char **argv){
sdlcleanup(&displayerer, images, dir, count, EXIT_FAILURE);
}
- mkdir("../saved", 0755);
- mkdir("../other", 0755);
- mkdir("../delete", 0755);
+ char saveddir[1024], otherdir[1024], deletedir[1024];
+ snprintf(saveddir, sizeof(saveddir), "%s/saved", path);
+ snprintf(otherdir, sizeof(otherdir), "%s/other", path);
+ snprintf(deletedir, sizeof(deletedir), "%s/delete", path);
+
+ mkdir(saveddir, 0755);
+ mkdir(otherdir, 0755);
+ mkdir(deletedir, 0755);
if(sdlinit(&displayerer)){
sdlcleanup(&displayerer, images, dir, count, EXIT_FAILURE);
@@ -208,7 +213,7 @@ int main(int argc, char **argv){
SDL_StopTextInput();
char *ext = strrchr(images[whichone], '.');
char savedbuf[1024];
- snprintf(savedbuf, sizeof(savedbuf), "../saved/%s%s", textbuf, ext ? ext : "");
+ snprintf(savedbuf, sizeof(savedbuf), "%s/%s%s", saveddir, textbuf, ext ? ext : "");
rename(images[whichone], savedbuf);
if(whichone + 1 < count){
whichone++;
@@ -237,7 +242,7 @@ int main(int argc, char **argv){
case SDL_SCANCODE_S:
if(!typing){
char otherbuf[1024];
- snprintf(otherbuf, sizeof(otherbuf), "../other/%s", strrchr(images[whichone], '/') + 1);
+ snprintf(otherbuf, sizeof(otherbuf), "%s/%s", otherdir, strrchr(images[whichone], '/') + 1);
rename(images[whichone], otherbuf);
if(whichone + 1 < count){
whichone++;
@@ -249,7 +254,7 @@ int main(int argc, char **argv){
case SDL_SCANCODE_D:
if(!typing){
char otherbuf[1024];
- snprintf(otherbuf, sizeof(otherbuf), "../delete/%s", strrchr(images[whichone], '/') + 1);
+ snprintf(otherbuf, sizeof(otherbuf), "%s/%s", deletedir, strrchr(images[whichone], '/') + 1);
rename(images[whichone], otherbuf);
if(whichone + 1 < count){
whichone++;