mirror of
https://github.com/troglobit/libite.git
synced 2026-10-06 15:30:07 +07:00
Remove fmode() from libite, it's safer to use stat() instead
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
/* File mode bit operations
|
||||
*
|
||||
* Copyright (c) 2008 Claudio Matsuoka <http://helllabs.org/finit/>
|
||||
*
|
||||
* 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 <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/**
|
||||
* 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:
|
||||
*/
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user