yaffs Yet more tests for quick tests.
[yaffs2.git] / direct / timothy_tests / quick_tests / lib.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2010 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Timothy Manning <timothy@yaffs.net>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #include "lib.h"
15
16
17 void join_paths(char *path1,char *path2,char *new_path ){
18
19         //strcat(new_path,path1);       /*since all functions have this then pull it out*/
20         if ( (path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]!='/') {
21                 /*paths are compatiable. concatanate them. note -2 is because of \0*/  
22                 strcat(new_path,path1);
23                 strcat(new_path,path2);         
24                 //char new_path[(sizeof(path1)/sizeof(char))+(sizeof(path2)/sizeof(char))];
25                 //strcpy(new_path,strcat(path1,path2)); 
26                 //return new_path;
27         }       
28         else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]=='/') {
29                 /*paths are compatiable. concatanate them*/  
30                 strcat(new_path,path1);
31                 strcat(new_path,path2);         
32
33         }
34         else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]!='/') {
35                         /*need to add a "/". */  
36                 strcat(new_path,path1);
37                 strcat(new_path,"/");
38                 strcat(new_path,path2);
39
40
41         }
42         else if ((path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]=='/') {
43                 /*need to remove a "/". */
44                 /*yaffs does not mind the extra slash. */               
45                 strcat(new_path,path1);
46                 strcat(new_path,path2);
47
48         } 
49         else{
50                 //error 
51                 //return -1;
52         }
53 }
54