From 07272e00ba2c97468b4bf97dab77e31e75b158c7 Mon Sep 17 00:00:00 2001 From: ronny Date: Wed, 19 Jun 2002 15:12:18 +0000 Subject: 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 --- backendC/CleanCompilerSources/unix_io.c | 78 +++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'backendC/CleanCompilerSources') 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