summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--src/lib/file.cpp23
-rw-r--r--src/lib/file.h13
3 files changed, 37 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 8e5235f..3e305ba 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ obj = obj/
all:
if [[ ! -d obj ]]; then mkdir obj; fi
+ g++ $(debug) -c $(libs)file.cpp -o $(obj)/file.o
g++ $(debug) -c $(libs)config.cpp -o $(obj)/config.o
g++ $(debug) -c $(libs)note.cpp -o $(obj)/note.o
g++ $(debug) -c $(libs)note_list.cpp -o $(obj)/note_list.o
diff --git a/src/lib/file.cpp b/src/lib/file.cpp
new file mode 100644
index 0000000..6b18277
--- /dev/null
+++ b/src/lib/file.cpp
@@ -0,0 +1,23 @@
+#include "file.h"
+
+file::file( string p ) {
+ // Parse path into parent dir array and filename
+ long cur_dir_begin = 0;
+ for( int i = 0; i < p.length(); i++ ) {
+ int cur_char = p[i];
+ int delim = '/';
+ // Parse the directories out of the path
+ // Skip the first if it's an absolute path
+ if( i == 0 && cur_char == delim ) {
+ // Do nothing
+ } else if( cur_char == delim ) {
+ // Check if we've hit a path delimiter (/ or \)
+ dirs.push_back( p.substr( cur_dir_begin, i - cur_dir_begin ) );
+ // Skip the slash since we don't need it
+ i++;
+ cur_dir_begin = i;
+ }
+ }
+ // Annnnnd output the filename...for now
+ name = p.substr( cur_dir_begin, p.length() - cur_dir_begin );
+}
diff --git a/src/lib/file.h b/src/lib/file.h
new file mode 100644
index 0000000..85c8852
--- /dev/null
+++ b/src/lib/file.h
@@ -0,0 +1,13 @@
+using namespace std;
+
+#include <string>
+#include <vector>
+#include <iostream>
+
+class file {
+ public:
+ string name;
+ vector<string> dirs;
+
+ file( string );
+};

Generated by cgit