diff options
author | ronny | 2002-06-19 15:12:18 +0000 |
---|---|---|
committer | ronny | 2002-06-19 15:12:18 +0000 |
commit | 07272e00ba2c97468b4bf97dab77e31e75b158c7 (patch) | |
tree | 2b304d2cac50a8910fc46e13acdf02935049a476 | |
parent | use macintosh newlines (diff) |
Different file finding method (now identical to windows_io method).
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@1123 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
-rw-r--r-- | backendC/CleanCompilerSources/unix_io.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/backendC/CleanCompilerSources/unix_io.c b/backendC/CleanCompilerSources/unix_io.c index a95ff3a..6646852 100644 --- a/backendC/CleanCompilerSources/unix_io.c +++ b/backendC/CleanCompilerSources/unix_io.c @@ -54,6 +54,83 @@ static int use_clean_system_files_folder=1; char *PATHLIST = SEARCHPATH; +static Bool file_exists (char *path) +{ + return access (path, F_OK) == 0; +} + +extern char *path_parameter; + +static Bool findfilepath (char *fname,FileKind kind,char *mode,char *path) +{ + char *s,*path_elem,c,*pathlist,*ext; + int in_clean_system_files_folder; + + if (path_parameter==NULL) + pathlist=getenv ("CLEANPATH"); + else + pathlist=path_parameter; + + if (pathlist==NULL) + pathlist="."; + + ext = GetFileExtension (kind); + + in_clean_system_files_folder=0; + + if (use_clean_system_files_folder) + switch (kind){ + case abcFile: + case obj00File: + case obj20File: + case obj81File: + in_clean_system_files_folder=1; + } + + + if (! (fname[0]=='/')){ + path_elem = pathlist; + + s=path_elem; + for (;;){ + c = *s; + if (c == ':' || c == '\0'){ + char *from_p,*dest_p; + + from_p=path_elem; + dest_p=path; + while (from_p<s) + *dest_p++ = *from_p++; + *dest_p = '\0'; + + if (in_clean_system_files_folder) + strcat (path,"/Clean System Files/"); + else + strcat (path,"/"); + strcat (path,fname); + strcat (path,ext); + if (file_exists (path)) + return True; + + if (c == '\0') + break; + + path_elem = ++s; + } else + ++s; + } + } + + if (in_clean_system_files_folder){ + strcpy (path,"Clean System Files/"); + strcat (path,fname); + } else + strcpy (path,fname); + strcat (path,ext); + + return file_exists (path); +} +#if 0 static Bool findfilepath (char *fname, FileKind kind, char *mode, char *path) { int accmode; @@ -138,6 +215,7 @@ static Bool findfilepath (char *fname, FileKind kind, char *mode, char *path) return ((Bool) (access (path, accmode) == 0)); } +#endif File FOpen (char *wname, FileKind kind, char *mode) { |