about summary refs log tree commit diff
path: root/src/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/base')
-rw-r--r--src/base/system.c14
-rw-r--r--src/base/system.h10
2 files changed, 24 insertions, 0 deletions
diff --git a/src/base/system.c b/src/base/system.c
index 5f4f9d0d..9a291045 100644
--- a/src/base/system.c
+++ b/src/base/system.c
@@ -984,6 +984,20 @@ int fs_chdir(const char *path)
 		return 1;
 }
 
+void fs_parent_dir(const char *path, char *buffer)
+{
+	int stop = 0;
+	int i = 0;
+	for(i = 0; i < 256; i++)
+	{
+		if(path[i] == '/')
+			stop = i+1;
+	}
+	
+	//keep the chars which are before the last '/' and remove the chars which are after
+	str_copy(buffer, path, stop);
+}
+
 void swap_endian(void *data, unsigned elem_size, unsigned num)
 {
 	char *src = (char*) data;
diff --git a/src/base/system.h b/src/base/system.h
index 1b4d52aa..c9d25260 100644
--- a/src/base/system.h
+++ b/src/base/system.h
@@ -945,6 +945,16 @@ int fs_is_dir(const char *path);
 int fs_chdir(const char *path);
 
 /*
+	Function: fs_parent_dir
+		Get the parent directory of a directory
+	
+	Parameters:
+		path - The directory
+		buffer - Buffer to set the parent folder
+*/
+void fs_parent_dir(const char *path, char *buffer);
+
+/*
 	Group: Undocumented
 */