summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@JOEL-UBUNTU.(none)>2007-12-19 21:33:05 +0900
committerJoel Bosveld <joel@JOEL-UBUNTU.(none)>2007-12-19 21:33:05 +0900
commit609ce9b912ee9d871807eda33caa666747f25957 (patch)
treebce69ac4056e6fd4f9c4978d92910690ed10455d
parentdb12db7c80833cd9f2740f1b6ea8880b8c616ba9 (diff)
downloadcubedbus-609ce9b912ee9d871807eda33caa666747f25957.tar.gz
cubedbus-609ce9b912ee9d871807eda33caa666747f25957.tar.bz2
Added function to get path.
Doesn't do anything yet, but I wanted to commit/push because I had accidentaly broken my repo
-rw-r--r--cubedbusModel.c.in44
1 files changed, 44 insertions, 0 deletions
diff --git a/cubedbusModel.c.in b/cubedbusModel.c.in
index ff865d8..bae01ef 100644
--- a/cubedbusModel.c.in
+++ b/cubedbusModel.c.in
@@ -585,3 +585,47 @@ getLine (FILE *fp)
return NULL;
}
+static char *
+findPath (char *object, char *file)
+{
+ char *filePath; /* string containing /full/path/to/file */
+ char *tmpPtr;
+
+ char *myObject=malloc(sizeof(char)*(strlen(object)+1));
+ char *myFile=malloc(sizeof(char)*(strlen(file)+1));
+ if(myObject == NULL || myFile == NULL) return NULL;
+
+ strcpy(myObject, object);
+ strcpy(myFile, file);
+
+ int i;
+ for(i=strlen(myObject);i>=0;i--)
+ {
+ if(myObject[i]=='/')
+ {
+ myObject[i]='\0'; /* end string at last / (gives path to object) */
+ tmpPtr=realloc(myObject, sizeof(char)*(i+1));
+ if(tmpPtr==NULL) return NULL;
+ myObject=tmpPtr;
+ }
+ }
+
+ for(i=strlen(myFile);i>=0;i--)
+ {
+ if(myFile[i]=='/')
+ {
+ i++;
+ break;
+ }
+ }
+
+ filePath=malloc(sizeof(char) * (strlen(myObject)+strlen(myFile) +1 )); /* XXX */
+ sprintf(filePath, "%s/%s", myObject, &myFile[i]);
+ free(myObject);
+ free(myFile);
+ tmpPtr=realloc(filePath, sizeof(char) * (strlen(filePath)+1));
+ if(tmpPtr != NULL) filePath=tmpPtr;
+
+ return filePath;
+}
+