• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

ink_file.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 /****************************************************************************
00025 
00026   ink_file.h
00027 
00028   File manipulation routines for libts
00029 
00030  ****************************************************************************/
00031 
00032 #ifndef _ink_file_h_
00033 #define _ink_file_h_
00034 
00035 #include "ink_config.h"
00036 
00037 #include <stdio.h>
00038 #include <sys/types.h>
00039 #include <dirent.h>
00040 
00041 #if HAVE_SYS_STATFS_H
00042 #include <sys/statfs.h>
00043 #endif
00044 
00045 #if HAVE_SYS_STATVFS_H
00046 #include <sys/statvfs.h>
00047 #endif
00048 
00049 // Darwin keeps statafs(2) in <sys/mount.h> ...
00050 #if HAVE_SYS_MOUNT_H
00051 #include <sys/mount.h>
00052 #endif
00053 
00054 /*===========================================================================*
00055 
00056                             Function Prototypes
00057 
00058  *===========================================================================*/
00059 
00060 // Cause ink_filepath_merge to fail if addpath is above rootpath
00061 //
00062 #define INK_FILEPATH_NOTABOVEROOT   0x01
00063 // internal: Only meaningful with INK_FILEPATH_NOTABOVEROOT
00064 #define INK_FILEPATH_SECUREROOTTEST 0x02
00065 // Cause ink_filepath_merge to fail if addpath is above rootpath,
00066 // even given a rootpath /foo/bar and an addpath ../bar/bash
00067 //
00068 #define INK_FILEPATH_SECUREROOT     0x03
00069 // Fail ink_filepath_merge if the merged path is relative
00070 #define INK_FILEPATH_NOTRELATIVE    0x04
00071 // Fail ink_filepath_merge if the merged path is absolute
00072 #define INK_FILEPATH_NOTABSOLUTE    0x08
00073 // Return the file system's native path format (e.g. path delimiters
00074 // of ':' on MacOS9, '\' on Win32, etc.)
00075 #define INK_FILEPATH_NATIVE         0x10
00076 // Resolve the true case of existing directories and file elements
00077 // of addpath, (resolving any aliases on Win32) and append a proper
00078 // trailing slash if a directory
00079 //
00080 #define INK_FILEPATH_TRUENAME       0x20
00081 
00082 int ink_fputln(FILE *stream, const char *s);
00083 int ink_file_fd_readline(int fd, int bufsize, char *buf);
00084 int ink_file_fd_writestring(int fd, const char *buf);
00085 int ink_filepath_merge(char *buf, int bufsz, const char *rootpath,
00086                        const char *addpath, int flags = INK_FILEPATH_TRUENAME);
00087 /**
00088  Add addpath to the rootpath prepending slash if rootpath
00089  is not NULL and doesn't end with the slash already and put the
00090  result into path buffer. If the buffer is too small to hold the
00091  resulting string, required size is returned. On success zero is returned
00092  */
00093 int ink_filepath_make(char *path, int pathsz, const char *rootpath,
00094                       const char *addpath);
00095 
00096 /**
00097  Resize and zero-fill the given file.
00098  Returns 0 on success, errno on failure.
00099  */
00100 int ink_file_fd_zerofill(int fd, off_t size);
00101 
00102 /**
00103  Return true if the path is a directory.
00104  */
00105 bool ink_file_is_directory(const char * path);
00106 #endif // _ink_file_h_

Generated by  doxygen 1.7.1