@@ -44,7 +44,7 @@ Metadata get_metadata(char file_name[]) {
44
44
// declare array
45
45
static Metadata metadata ;
46
46
47
- // open stram
47
+ // open stream
48
48
FILE * ptr_file = fopen (file_name , "r" );
49
49
if (ptr_file == NULL ) {
50
50
fprintf (stderr , "%s[ERROR]%s: Failed while opening the file\n" , color_red , color_reset );
@@ -58,11 +58,11 @@ Metadata get_metadata(char file_name[]) {
58
58
while (fgets (field , MAX_FIELD_SIZE , ptr_file ) != NULL && fgets (value , MAX_VALUE_SIZE , ptr_file ) != NULL ) {
59
59
60
60
// if "Tag"/"Argument" line then save value and set boolean
61
- if (strncmp (field , "Tag" , 3 )) {
61
+ if (strncmp (field , "Tag" , 3 ) == 0 ) {
62
62
strcpy (metadata .tags , value );
63
- } else if (strncmp (field , "Argument" , 8 )) {
63
+ } else if (strncmp (field , "Argument" , 8 ) == 0 ) {
64
64
strcpy (metadata .arguments , value );
65
- } else if (strcmp (field , "---\n" )) {
65
+ } else if (strcmp (field , "---\n" ) == 0 ) {
66
66
if (!twice ) {
67
67
twice = true;
68
68
} else {
@@ -117,7 +117,7 @@ void new(char file_name[]) {
117
117
while (fgets (field , MAX_FIELD_SIZE , ptr_template ) != NULL ) {
118
118
119
119
// if the string is the start/end of the metadata section ot the new line at the bottom
120
- if (strcmp (field , "---\n" ) && strcmp (field , "\n" )) {
120
+ if (strcmp (field , "---\n" ) != 0 && strcmp (field , "\n" ) != 0 ) {
121
121
122
122
// null terminate string
123
123
field [strcspn (field , "\n" )] = '\0' ;
@@ -128,9 +128,9 @@ void new(char file_name[]) {
128
128
// get input from stdin
129
129
fgets (value , sizeof (value ), stdin );
130
130
131
- if (strncmp (field , "Tag" , 3 )) {
131
+ if (strncmp (field , "Tag" , 3 ) == 0 ) {
132
132
strcpy (tags , value );
133
- } else if (strncmp (field , "Argument" , 8 )) {
133
+ } else if (strncmp (field , "Argument" , 8 ) == 0 ) {
134
134
strcpy (arguments , value );
135
135
}
136
136
@@ -152,13 +152,13 @@ void save(char file_name[]) {
152
152
metadata = get_metadata (file_name );
153
153
154
154
// create basic folders if they don't already exist
155
- mkdir ("./notes " , 0777 );
156
- mkdir ("./notes /arguments" , 0777 );
157
- mkdir ("./notes /tags" , 0777 );
155
+ mkdir ("./note " , 0777 );
156
+ mkdir ("./note /arguments" , 0777 );
157
+ mkdir ("./note /tags" , 0777 );
158
158
159
159
// create the local path to the right tag folder
160
160
char arguments_file [MAX_VALUE_SIZE ];
161
- strcpy (arguments_file , "./notes /arguments/" );
161
+ strcpy (arguments_file , "./note /arguments/" );
162
162
strcat (arguments_file , metadata .arguments );
163
163
strcat (arguments_file , ".md" );
164
164
@@ -186,7 +186,7 @@ void save(char file_name[]) {
186
186
187
187
// create the local path to the right tag folder
188
188
char tags_folder [MAX_VALUE_SIZE ];
189
- strcpy (tags_folder , "./notes /tags/" );
189
+ strcpy (tags_folder , "./note /tags/" );
190
190
strcat (tags_folder , metadata .tags );
191
191
192
192
// create the folder if not already exists
@@ -220,13 +220,13 @@ int main(int argc, char* argv[]) {
220
220
strcpy (flag , argv [1 ]);
221
221
222
222
// check if creating file
223
- if (strcmp (flag , "-n" ) || strcmp (flag , "--new" )) {
223
+ if (strcmp (flag , "-n" ) == 0 || strcmp (flag , "--new" ) == 0 ) {
224
224
// get file name
225
225
char file_name [MAX_FILENAME_SIZE ];
226
226
strcpy (file_name , argv [2 ]);
227
227
228
228
new (file_name );
229
- } else if (strcmp (flag , "-s" ) || strcmp (flag , "--save" )) {
229
+ } else if (strcmp (flag , "-s" ) == 0 || strcmp (flag , "--save" ) == 0 ) {
230
230
// get file name
231
231
char file_name [MAX_FILENAME_SIZE ];
232
232
strcpy (file_name , argv [2 ]);
0 commit comments