Add extension ignore list & vscode configs

This commit is contained in:
realaltffour 2020-04-25 14:09:43 +03:00
parent 26576264b5
commit 2a4ce1e8da
No known key found for this signature in database
GPG Key ID: 7115CD2AC9A76A56
2 changed files with 38 additions and 4 deletions

27
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,27 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/fixmydl",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bin/",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

View File

@ -1,4 +1,3 @@
/*This is the sample program to notify us for the file creation and file deletion takes place in “/tmp” directory*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -12,6 +11,9 @@
#define EVENT_SIZE (sizeof(struct inotify_event))
#define EVENT_BUF_LEN (1024 * (EVENT_SIZE + 16))
static const int IGNORE_LIST_SIZE = 2;
static const char *extension_ignore_list[] = { "crdownload\0", "test2\0" };
static const char misc_dir_default[] = "misc";
static const char downloads_dir_default[] = "Downloads";
@ -78,7 +80,6 @@ void move(const char *name)
{
/* Get all variables needed */
char *ext = get_extension(name);
char *dest = (char *)malloc(4096 * sizeof(char));
sprintf(dest, "%s/%s/%s", documents_dir, ext, name);
char *src = (char *)malloc(4096 * sizeof(char));
@ -86,6 +87,12 @@ void move(const char *name)
char *org = (char *)malloc(4096 * sizeof(char));
sprintf(org, "%s/%s/", documents_dir, ext);
/* Check if extension is not to be used */
for (unsigned int i = 0; i < IGNORE_LIST_SIZE; i++) {
if (strcmp(extension_ignore_list[i], ext) == 0)
return;
}
/* Ensure/Create directories for organization */
char *cmd = (char *)malloc(8096 * 2.5 * sizeof(char));
strcat(cmd, "mkdir --parents ");
@ -143,9 +150,9 @@ char *get_directory(const char *name)
}
strcat(result, home_dir);
strcat(result, "/");
if (strcmp(name, "DOWNLOAD"))
if (strcmp(name, "DOWNLOAD") == 0)
strcat(result, downloads_dir_default);
else if (strcmp(name, "DOCUMENTS"))
else if (strcmp(name, "DOCUMENTS") == 0)
strcat(result, documents_dir_default);
} else {
/* Read path from output of xdg */