summaryrefslogtreecommitdiff
path: root/src/note_list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/note_list.c')
-rw-r--r--src/note_list.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/note_list.c b/src/note_list.c
index 0376508..79b9aa9 100644
--- a/src/note_list.c
+++ b/src/note_list.c
@@ -146,13 +146,31 @@ void note_list_free(note_list_t* list) {
*
* @return int Success or failure (always success for now)
*/
-// int note_list::create( string editor, string note_name ) {
-// string spath = _dirname + '/' + note_name + '.' + _ext;
-// path p( spath );
-// note n( p );
-// n.edit( editor );
-// return 0;
-// }
+int note_list_create_note(note_list_t* list, char* editor, char* note_name) {
+ char tmp_note_name[64];
+ strcpy(tmp_note_name, note_name);
+ strcat(tmp_note_name, ".");
+ strcat(tmp_note_name, list->extension);
+
+ // Check if note already exists
+ for(int i = 0; i < list->count; i++) {
+ if(strcmp(list->names[i], tmp_note_name) == 0) {
+ return 1;
+ }
+ }
+
+ // Construct full note path
+ char note_path[256];
+ strcpy(note_path, list->path);
+ strcat(note_path, "/");
+ strcat(note_path, tmp_note_name);
+
+ note_t note;
+ note_new(&note, note_path);
+ note_edit(&note, editor);
+
+ return 0;
+}
/**

Generated by cgit