Made bitmap view and path AppMessage targets. Picture files can now be
[AROS.git] / arch / arm-native / ceboot / filesystem.c
blob05cc9aaf95cfcb29b36c9fcabfbf35440410d41a
1 /*
2 Copyright © 2010-2011, The AROS Development Team. All rights reserved.
3 $Id: filesystem.c 43148 2011-12-21 11:18:56Z sonic $
5 Desc: Filesystem control routines
6 Lang: english
7 */
9 #include <dirent.h>
10 #include <stdio.h>
11 #include <string.h>
12 #include <windows.h>
13 #include <sys/stat.h>
15 #include "bootstrap.h"
16 #include "filesystem.h"
18 char *namepart(char *name)
20 while (*name)
21 name++;
23 while((name[-1] != ':') && (name[-1] != '\\') && (name[-1] != '/'))
24 name--;
26 return name;
29 static char *GetAbsName(const char *filename)
31 int l1 = strlen(bootstrapdir);
32 char *absname = malloc(l1 + strlen(filename) + 1);
34 if (absname)
36 memcpy(absname, bootstrapdir, l1);
37 strcpy(&absname[l1], filename);
40 return absname;
43 FILE *file_open(const char *filename, const char *mode)
45 FILE *res;
46 char *absname;
48 if (*filename == '\\')
50 /* The path is given as absolute, just use it */
51 return fopen(filename, mode);
54 absname = GetAbsName(filename);
55 if (!absname)
56 return NULL;
58 res = fopen(absname, mode);
59 free(absname);
61 return res;
64 int SetLog(const char *filename)
66 FILE *res;
68 if (*filename != '\\')
70 char *absname = GetAbsName(filename);
72 if (!absname)
73 return GetLastError();
75 res = freopen(absname, "a", stderr);
76 free(absname);
78 else
80 /* The path is given as absolute, just use it */
81 res = freopen(filename, "a", stderr);
83 return res ? 0 : GetLastError();