diff options
author | lonkaars <loek@pipeframe.xyz> | 2021-05-30 09:52:41 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2021-05-30 09:52:41 +0200 |
commit | 760a8fea16531d199f48b9ec84cad2a08970726b (patch) | |
tree | b97ea8f56814f09aa98fa3d8c6c79f6fcb5dd0e5 | |
parent | 3fe4b144cddad9af5332ad32387404f03aaf60aa (diff) |
the config file do be reading
-rw-r--r-- | musicopy.c | 21 | ||||
-rw-r--r-- | rc.ini | 15 |
2 files changed, 36 insertions, 0 deletions
@@ -1,6 +1,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <unistd.h> #include <ini.h> #include <cwalk.h> @@ -10,11 +11,31 @@ int main() { printf("$HOME could not be read! exiting...\n"); exit(1); } + char* config_file_loc = ".config/musicopy/rc.ini"; size_t config_path_size = (strlen(home) + strlen(config_file_loc) + 4) * sizeof(char); char* config_path = malloc(config_path_size); cwk_path_join(home, config_file_loc, config_path, config_path_size); + if( access(config_path, F_OK) != 0 ) { + printf("Config file can't be read! exiting...\n"); + exit(1); + } + FILE* config_file_handle = fopen(config_path, "rw"); + long config_file_length; + char* config_file_buffer = 0; + + fseek(config_file_handle, 0, SEEK_END); + config_file_length = ftell(config_file_handle); + fseek(config_file_handle, 0, SEEK_SET); + config_file_buffer = malloc(config_file_length); + if(!config_file_buffer) { + printf("An error occured allocating memory for the config file! exiting...\n"); + exit(1); + } + fread(config_file_buffer, 1, config_file_length, config_file_handle); + printf("%s\n", config_path); + printf("%s\n", config_file_buffer); return 0; } @@ -0,0 +1,15 @@ +[default] +music_dir = ~/music +playlist_dir = ~/playlists + +# exclude = junk/** +# i don't like this music/** + +# include = folders to include/** + +# don't copy existing files +# lazy = only check file size +# full = compare sha1 hash +# none = blindly overwrite files +# existing = lazy + |