a7219c59f31d303f31ac2757902ae2fba19278d9
[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
20         //strcat(new_path,path1);       /*since all functions have this then pull it out*/
21         if ( (path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]!='/') {
22                 /*paths are compatiable. concatanate them. note -2 is because of \0*/  
23                 strcat(new_path,path1);
24                 strcat(new_path,path2);         
25                 //char new_path[(sizeof(path1)/sizeof(char))+(sizeof(path2)/sizeof(char))];
26                 //strcpy(new_path,strcat(path1,path2)); 
27                 //return new_path;
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         } else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]!='/') {
34                         /*need to add a "/". */  
35                 strcat(new_path,path1);
36                 strcat(new_path,"/");
37                 strcat(new_path,path2);
38
39         } else if ((path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]=='/') {
40                 /*need to remove a "/". */
41                 /*yaffs does not mind the extra slash. */               
42                 strcat(new_path,path1);
43                 strcat(new_path,path2);
44
45         } else {
46                 //error 
47                 //return -1;
48         }
49 }
50
51 void print_message(char *message,char print_level)
52 {
53         if (print_level <= PRINT_LEVEL){
54                 printf(message);
55         }
56 }
57         
58
59