-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovw.c
More file actions
33 lines (27 loc) · 807 Bytes
/
Copy pathmovw.c
File metadata and controls
33 lines (27 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
int main(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: movw <fichier_ou_dossier>\n");
return 1;
}
char wdir[MAX_PATH_LEN];
if (!load_w_dir(wdir, sizeof(wdir))) {
printf("Erreur: impossible de lire w-config.ini\n");
return 1;
}
// créer le dossier W si nécessaire
char cmd[1024];
snprintf(cmd, sizeof(cmd), "mkdir \"%s\" >nul 2>&1", wdir);
system(cmd);
// move
snprintf(cmd, sizeof(cmd), "move \"%s\" \"%s\" >nul", argv[1], wdir);
if (system(cmd) != 0) {
printf("Erreur: impossible de déplacer %s vers %s\n", argv[1], wdir);
return 1;
}
printf("Déplacé dans %s : %s\n", wdir, argv[1]);
return 0;
}