diff options
-rw-r--r-- | src/note.c | 29 |
1 files changed, 9 insertions, 20 deletions
@@ -53,10 +53,11 @@ int note_edit(note_t* note, char* editor) { /** - * Reads in the contents of the note. This exists so we don't have to keep - * writing the file open, check, get line, blah blah blah repeatedly. + * Prints the contents of the specified note. * - * @return void + * @return int Status of the cat operation. + * 0 Success + * -1 File could not be opened */ int note_cat(note_t* note) { FILE* f = fopen(note->path, "r"); @@ -64,28 +65,16 @@ int note_cat(note_t* note) { if(!f) { return -1; } char c; + // Print the contents of the note while((c = fgetc(f)) != EOF) { printf("%c", c); } + + // Close up shop fclose(f); + printf("\n"); - //// Don't do this unless body hasn't already been read - //if( body.size() == 0 ) { - // // Open the file - // ifstream fs( _path.out().c_str() ); - - // // Verify the file handle opened sucessfully - // if( ! fs.is_open() ) { - // cout << "Could not open file at " << _path.out() << "." << endl; - // exit( 1 ); - // } - - // string line; - // while( getline( fs, line ) ) { - // body.push_back( line ); - // } - // fs.close(); - //} + return 0; } |