00001 /* Part of the culibs project, <http://www.eideticdew.org/culibs/>. 00002 * Copyright (C) 2008--2009 Petter Urkedal <urkedal@nbi.dk> 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef CUOS_FILE_H 00019 #define CUOS_FILE_H 00020 00021 #include <cu/fwd.h> 00022 #include <cu/algo.h> 00023 #include <stdio.h> 00024 00025 CU_BEGIN_DECLARATIONS 00026 /** \defgroup cuos_file_h cuos/file.h: Functions on Files 00027 ** @{ \ingroup cuos_mod */ 00028 00029 /** Returns the ordering relation of the content of the files at \a path0 and 00030 ** \a path1, or \ref cu_order_none if an error occured. The order is that of 00031 ** the first differing byte, where EOF is taken as zero. When en error 00032 ** occurs, \c errno will be set by \c fopen. */ 00033 cu_order_t cuos_file_order(cu_str_t path0, cu_str_t path1); 00034 00035 /** If the file at \a tmp_path differ or cannot be compared to that at \a 00036 ** dst_path, renames \a tmp_path to \a dst_path (overwriting the latter) and 00037 ** returns 1, otherwise removes \a tmp_path and returns 0. In case of error 00038 ** -1 is returned, and \c errno is set by the system \c unlink or \c rename 00039 ** call. */ 00040 int cuos_file_update(cu_str_t tmp_path, cu_str_t dst_path); 00041 00042 /** Calls \c fopen with \a path converted to a C string. */ 00043 FILE *cuos_fopen(cu_str_t path, char const *mode); 00044 00045 /** @} */ 00046 CU_END_DECLARATIONS 00047 00048 #endif