00001 00004 /* Copyright (C) 2006,2007 Olly Betts 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #ifndef XAPIAN_INCLUDED_FLINT_IO_H 00022 #define XAPIAN_INCLUDED_FLINT_IO_H 00023 00024 #include <sys/types.h> 00025 #include "safefcntl.h" 00026 #include "safeunistd.h" 00027 00033 inline bool flint_io_sync(int fd) 00034 { 00035 // If we have it, prefer fdatasync() as it avoids updating the access time 00036 // so is probably a little more efficient. 00037 #if defined HAVE_FDATASYNC 00038 return fdatasync(fd) == 0; 00039 #elif defined HAVE_FSYNC 00040 return fsync(fd) == 0; 00041 #elif defined __WIN32__ 00042 return _commit(fd) == 0; 00043 #else 00044 # error Cannot implement flint_io_sync() without fdatasync(), fsync(), or _commit() 00045 #endif 00046 } 00047 00055 size_t flint_io_read(int fd, char * p, size_t n, size_t min); 00056 00058 void flint_io_write(int fd, const char * p, size_t n); 00059 00060 #endif