summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@iohq.net>2015-02-25 11:06:59 -0700
committerAaron Ball <nullspoon@iohq.net>2015-02-25 11:06:59 -0700
commitc6acb00c71c7a09cb5a29fc0d48ab1052d5689b4 (patch)
tree78cf6663459b3420034d70c15d31850d8f2c7605
parentde3ee4e2c472dfd032c7ee580fcf67721f74623e (diff)
downloadnoteless-c6acb00c71c7a09cb5a29fc0d48ab1052d5689b4.tar.gz
noteless-c6acb00c71c7a09cb5a29fc0d48ab1052d5689b4.tar.xz
Cleanup from previous commit (note_cat)
Removed commented out c++. Added more comments to note_cat function for better documentation.
-rw-r--r--src/note.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/note.c b/src/note.c
index 71f495f..2bc828d 100644
--- a/src/note.c
+++ b/src/note.c
@@ -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;
}

Generated by cgit