"Fossies" - the Fresh Open Source Software Archive

Member "eucalyptus-4.4.2/util/euca_file.h" (4 Aug 2017, 8780 Bytes) of package /linux/misc/eucalyptus-4.4.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "euca_file.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 4.4.1_vs_4.4.2.

    1 // -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
    2 // vim: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
    3 
    4 /*************************************************************************
    5  * Copyright 2009-2012 Eucalyptus Systems, Inc.
    6  *
    7  * This program is free software: you can redistribute it and/or modify
    8  * it under the terms of the GNU General Public License as published by
    9  * the Free Software Foundation; version 3 of the License.
   10  *
   11  * This program is distributed in the hope that it will be useful,
   12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  * GNU General Public License for more details.
   15  *
   16  * You should have received a copy of the GNU General Public License
   17  * along with this program.  If not, see http://www.gnu.org/licenses/.
   18  *
   19  * Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
   20  * CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
   21  * additional information or have any questions.
   22  *
   23  * This file may incorporate work covered under the following copyright
   24  * and permission notice:
   25  *
   26  *   Software License Agreement (BSD License)
   27  *
   28  *   Copyright (c) 2008, Regents of the University of California
   29  *   All rights reserved.
   30  *
   31  *   Redistribution and use of this software in source and binary forms,
   32  *   with or without modification, are permitted provided that the
   33  *   following conditions are met:
   34  *
   35  *     Redistributions of source code must retain the above copyright
   36  *     notice, this list of conditions and the following disclaimer.
   37  *
   38  *     Redistributions in binary form must reproduce the above copyright
   39  *     notice, this list of conditions and the following disclaimer
   40  *     in the documentation and/or other materials provided with the
   41  *     distribution.
   42  *
   43  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   44  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   45  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   46  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   47  *   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   48  *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   49  *   BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   50  *   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   51  *   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   52  *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   53  *   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   54  *   POSSIBILITY OF SUCH DAMAGE. USERS OF THIS SOFTWARE ACKNOWLEDGE
   55  *   THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE LICENSED MATERIAL,
   56  *   COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS SOFTWARE,
   57  *   AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
   58  *   IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA,
   59  *   SANTA BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY,
   60  *   WHICH IN THE REGENTS' DISCRETION MAY INCLUDE, WITHOUT LIMITATION,
   61  *   REPLACEMENT OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO
   62  *   IDENTIFIED, OR WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT
   63  *   NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
   64  ************************************************************************/
   65 
   66 #ifndef _INCLUDE_EUCA_FILE_H_
   67 #define _INCLUDE_EUCA_FILE_H_
   68 
   69 //!
   70 //! @file util/euca_file.h
   71 //! This file defines the various file and directory utility functions
   72 //!
   73 
   74 /*----------------------------------------------------------------------------*\
   75  |                                                                            |
   76  |                                  INCLUDES                                  |
   77  |                                                                            |
   78 \*----------------------------------------------------------------------------*/
   79 
   80 #include "data.h"
   81 
   82 /*----------------------------------------------------------------------------*\
   83  |                                                                            |
   84  |                                  DEFINES                                   |
   85  |                                                                            |
   86 \*----------------------------------------------------------------------------*/
   87 
   88 /*----------------------------------------------------------------------------*\
   89  |                                                                            |
   90  |                                  TYPEDEFS                                  |
   91  |                                                                            |
   92 \*----------------------------------------------------------------------------*/
   93 
   94 /*----------------------------------------------------------------------------*\
   95  |                                                                            |
   96  |                                ENUMERATIONS                                |
   97  |                                                                            |
   98 \*----------------------------------------------------------------------------*/
   99 
  100 /*----------------------------------------------------------------------------*\
  101  |                                                                            |
  102  |                                 STRUCTURES                                 |
  103  |                                                                            |
  104 \*----------------------------------------------------------------------------*/
  105 
  106 /*----------------------------------------------------------------------------*\
  107  |                                                                            |
  108  |                             EXPORTED VARIABLES                             |
  109  |                                                                            |
  110 \*----------------------------------------------------------------------------*/
  111 
  112 /*----------------------------------------------------------------------------*\
  113  |                                                                            |
  114  |                             EXPORTED PROTOTYPES                            |
  115  |                                                                            |
  116 \*----------------------------------------------------------------------------*/
  117 
  118 int euca_rmdir(const char *psPath, boolean force);
  119 int euca_sanitize_path(const char *psPath);
  120 
  121 int check_directory(const char *dir);
  122 int check_file_newer_than(const char *file, time_t mtime);
  123 int check_block(const char *file);
  124 int check_file(const char *file);
  125 int check_path(const char *path);
  126 int statfs_path(const char *path, unsigned long long *fs_bytes_size, unsigned long long *fs_bytes_available, int *fs_id);
  127 char *fp2str(FILE * fp);
  128 
  129 int cat(const char *file_name);
  130 int touch(const char *path);
  131 int diff(const char *path1, const char *path2);
  132 long long dir_size(const char *path);
  133 int write2file(const char *path, char *str);
  134 char *file2strn(const char *path, const ssize_t limit);
  135 char *file2str(const char *path);
  136 char *file2str_seek(char *file, size_t size, int mode);
  137 int str2file(const char *str, char *path, int flags, mode_t mode, boolean mktemp);
  138 int copy_file(const char *src, const char *dst);
  139 long long file_size(const char *file_path);
  140 void dedup_path(char *src_path);
  141 int ensure_directories_exist(const char *path, int is_file_path, const char *user, const char *group, mode_t mode);
  142 int safe_mkstemp(char *template);
  143 
  144 /*----------------------------------------------------------------------------*\
  145  |                                                                            |
  146  |                           STATIC INLINE PROTOTYPES                         |
  147  |                                                                            |
  148 \*----------------------------------------------------------------------------*/
  149 
  150 /*----------------------------------------------------------------------------*\
  151  |                                                                            |
  152  |                                   MACROS                                   |
  153  |                                                                            |
  154 \*----------------------------------------------------------------------------*/
  155 
  156 /*----------------------------------------------------------------------------*\
  157  |                                                                            |
  158  |                          STATIC INLINE IMPLEMENTATION                      |
  159  |                                                                            |
  160 \*----------------------------------------------------------------------------*/
  161 
  162 #endif /* ! _INCLUDE_EUCA_FILE_H_ */