diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2000-12-22 20:27:57 -0500 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2000-12-22 20:27:57 -0500 |
commit | 244b955fa0312faea2e138d55330bd9a81fd92de (patch) | |
tree | 80e6d4330a5f7e04567967694daf88575574cfb8 /WWW/Library/Implementation/HTFile.c | |
parent | 4bcb5704f4f3f96436217702000f32c859b621fb (diff) | |
download | lynx-snapshots-244b955fa0312faea2e138d55330bd9a81fd92de.tar.gz |
snapshot of project "lynx", label v2-8-4dev_15
Diffstat (limited to 'WWW/Library/Implementation/HTFile.c')
-rw-r--r-- | WWW/Library/Implementation/HTFile.c | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index 41627cdb..3e990097 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -138,11 +138,6 @@ PRIVATE HTSuffix no_suffix = { "*", NULL, NULL, NULL, 1.0 }; PRIVATE HTSuffix unknown_suffix = { "*.*", NULL, NULL, NULL, 1.0}; -#ifdef _WINDOWS -#define exists(p) (access(p,0)==0) -#endif - - /* To free up the suffixes at program exit. ** ---------------------------------------- */ @@ -233,13 +228,8 @@ PRIVATE void LYListFmtParse ARGS5( #define PTBIT(a, s) PBIT(a, 0, 0) #endif -#ifdef _WINDOWS - if (stat(file, &st) < 0) - fmtstr = " %a"; /* can't stat so just do anchor */ -#else if (lstat(file, &st) < 0) fmtstr = " %a"; /* can't stat so just do anchor */ -#endif StrAllocCopy(str, fmtstr); s = str; @@ -1995,7 +1985,6 @@ PRIVATE int print_local_dir ARGS5( } } /* end printing out the tree in order */ - closedir(dp); FREE(logical); FREE(tmpfilename); FREE(tail); @@ -2015,6 +2004,40 @@ PRIVATE int print_local_dir ARGS5( #endif /* HAVE_READDIR */ +#ifndef VMS +PUBLIC int HTStat ARGS2( + CONST char *, filename, + struct stat *, data) +{ + int result = -1; + char *temp_name = NULL; + size_t len = strlen(filename); + + if (len != 0 && LYIsPathSep(filename[len-1])) { + HTSprintf0(&temp_name, "%s.", filename); + } else { + temp_name = (char *)filename; + } +#ifdef _WINDOWS + /* + * Someone claims that stat() doesn't give the proper result for a + * directory on Windows. + */ + if (access(temp_name, 0) == 0) { + if (stat(temp_name, data) == -1) data->st_mode = S_IFDIR; + return 0; + } + return -1; +#else + return stat(temp_name, data); +#endif + + if (temp_name != filename) { + FREE(temp_name); + } + return result; +} +#endif /* Load a document. ** ---------------- @@ -2465,21 +2488,13 @@ PUBLIC int HTLoadFile ARGS4( ** will hold the directory entry, and a type 'DIR' which is used ** to point to the current directory being read. */ -#ifdef _WINDOWS - if (!exists(localname)) -#else - if (stat(localname,&dir_info) == -1) /* get file information */ -#endif + if (HTStat(localname,&dir_info) == -1) /* get file information */ { /* if can't read file information */ CTRACE((tfp, "HTLoadFile: can't stat %s\n", localname)); } else { /* Stat was OK */ -#ifdef _WINDOWS - if (stat(localname,&dir_info) == -1) dir_info.st_mode = S_IFDIR; -#endif - if (S_ISDIR(dir_info.st_mode)) { /* ** If localname is a directory. @@ -2500,7 +2515,6 @@ PUBLIC int HTLoadFile ARGS4( return HTLoadError(sink, 403, DISALLOWED_DIR_SCAN); } - if (HTDirAccess == HT_DIR_SELECTIVE) { char * enable_file_name = NULL; @@ -2527,6 +2541,7 @@ PUBLIC int HTLoadFile ARGS4( status = print_local_dir(dp, localname, anchor, format_out, sink); + closedir(dp); FREE(localname); FREE(nodename); return status; /* document loaded, maybe partial */ |