libexplain  1.4.D001
libexplain/ac/sys/stat.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - a library of system-call-specific strerror replacements
00003  * Copyright (C) 2012-2014 Peter Miller
00004  * Written by Peter Miller <pmiller@opensource.org.au>
00005  *
00006  * This program is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 3 of the License, or (at your
00009  * option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00014  * License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 #include <libexplain/ac/errno.h>
00021 #include <libexplain/ac/fcntl.h>
00022 #include <libexplain/ac/sys/stat.h>
00023 
00024 #include <libexplain/gcc_attributes.h>
00025 
00026 #undef utimens
00027 
00028 #ifndef HAVE_UTIMENS
00029 
00030 /*
00031  * Set the access and modification time stamps of FILE to be
00032  * TIMESPEC[0] and TIMESPEC[1], respectively.
00033  */
00034 int utimens(char const *path, const struct timespec timespec[2])
00035     LIBEXPLAIN_LINKAGE_HIDDEN;
00036 
00037 int
00038 utimens(char const *path, const struct timespec timespec[2])
00039 {
00040 #ifndef HAVE_UTIMENSAT
00041     (void)path;
00042     (void)timespec[0].tv_sec;
00043     errno = ENOSYS;
00044     return -1;
00045 #else
00046     return utimensat(AT_FDCWD, path, timespec, 0);
00047 #endif
00048 }
00049 
00050 #endif /* utimens */
00051 
00052 #ifndef HAVE_LUTIMENS
00053 
00054 int lutimens(char const *path, const struct timespec timespec[2])
00055     LIBEXPLAIN_LINKAGE_HIDDEN;
00056 
00057 int
00058 lutimens(char const *path, const struct timespec timespec[2])
00059 {
00060 #ifndef HAVE_UTIMENSAT
00061     (void)path;
00062     (void)timespec[0].tv_sec;
00063     errno = ENOSYS;
00064     return -1;
00065 #else
00066     return utimensat(AT_FDCWD, path, timespec, AT_SYMLINK_NOFOLLOW);
00067 #endif
00068 }
00069 
00070 #endif /* utimens */
00071 
00072 
00073 /* vim: set ts=8 sw=4 et : */