Skip to content
This repository has been archived by the owner on Aug 28, 2018. It is now read-only.

Commit

Permalink
Downward integrate
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleepwalking committed Jul 27, 2014
1 parent d2d5127 commit 827366f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/IO/File.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "File.h"
#include <libgen.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -218,6 +220,22 @@ int File_IsFile(String* Path)
return 1;
}

void DirFromFilePath(String* Dest, String* Sorc)
{
char* Temp = strdup(String_GetChars(Sorc));
char* DirName = dirname(Temp);
String_SetChars(Dest, DirName);
free(Temp);
}

void BaseFromFilePath(String* Dest, String* Sorc)
{
char* Temp = strdup(String_GetChars(Sorc));
char* DirName = basename(Temp);
String_SetChars(Dest, DirName);
free(Temp);
}

//Template Reads & Writes
#if 0
#include "_File.rc"
Expand Down
3 changes: 3 additions & 0 deletions src/IO/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ void File_WriteLine(File* This, String* Sorc);

int File_IsFile(String* Path);

void DirFromFilePath(String* Dest, String* Sorc);
void BaseFromFilePath(String* Dest, String* Sorc);

//Template Reads & Writes
#if 0
#include "_File.h"
Expand Down

0 comments on commit 827366f

Please sign in to comment.