From 62334c80fd4647d2d3bf7bd63117c358f28136f8 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 22 Nov 2017 12:51:49 +0100 Subject: [PATCH] Remove fmode() from libite, it's safer to use stat() instead Signed-off-by: Joachim Nilsson --- README.md | 4 ---- src/Makefile.am | 1 - src/fmode.c | 56 ------------------------------------------------- src/lite.h | 1 - 4 files changed, 62 deletions(-) delete mode 100644 src/fmode.c diff --git a/README.md b/README.md index 48a7264..4b11d5d 100644 --- a/README.md +++ b/README.md @@ -175,10 +175,6 @@ Generic Functions Check for the existence of a directory, returns True(1) or False(0). -- `fmode(file)` - - Returns the `mode_t` bits of a file or directory. - - `fsendfile(src, dst, len)` Copy data between file streams, very similar to `fcopyfile()`, but diff --git a/src/Makefile.am b/src/Makefile.am index ce922f5..9882a3e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,6 @@ libite_la_SOURCES = chomp.c copyfile.c \ conio.c conio.h \ dir.c \ fexist.c fisdir.c \ - fmode.c \ fparseln.c fsendfile.c \ ifconfig.c lfile.c \ makepath.c progress.c \ diff --git a/src/fmode.c b/src/fmode.c deleted file mode 100644 index e85ae83..0000000 --- a/src/fmode.c +++ /dev/null @@ -1,56 +0,0 @@ -/* File mode bit operations - * - * Copyright (c) 2008 Claudio Matsuoka - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include -#include -#include -#include - -/** - * fmode - Return a file's mode bits. - * @file: File to look for, with full path. - * - * Returns: - * The mode bits or zero when @file does not exist and errno set to %ENOENT. - */ -mode_t fmode(char *file) -{ - struct stat sb; - - if (!file) { - errno = EINVAL; - return 0; - } - - if (!stat(file, &sb)) - return sb.st_mode; - - return 0; -} - -/** - * Local Variables: - * indent-tabs-mode: t - * c-file-style: "linux" - * End: - */ diff --git a/src/lite.h b/src/lite.h index 2d31e51..8389c7b 100644 --- a/src/lite.h +++ b/src/lite.h @@ -57,7 +57,6 @@ char *fparseln (FILE *, size_t *, size_t *, const char[3], int); int fexist (char *file); int fisdir (const char *file); -mode_t fmode (char *file); FILE *tempfile (void); ssize_t copyfile (char *src, char *dst, int len, int opt);