
Definition in file FileUtil.C.
#include "Util/FileUtil.H"
#include "Util/log.H"
#include "rutz/bzip2stream.h"
#include "rutz/gzstreambuf.h"
#include "rutz/shared_ptr.h"
#include <cstring>
#include <fstream>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
Include dependency graph for FileUtil.C:

Go to the source code of this file.
Functions | |
| FILE * | stdOutputFileOpen (const std::string &fname, bool *owned) |
| Like fopen(fname, "w"), with some special cases. | |
| bool | hasExtension (const std::string &str, const std::string &ext) |
| case-INsensitive check of whether str ends with ext | |
| std::string | dotExtension (const std::string &in) |
| get the filename extension, INCLUDING the dot (e.g. ".jpg") | |
| std::string | nodotExtension (const std::string &in, std::string *base_out) |
| get the filename extension, EXCLUDING the dot (e.g., "jpg") | |
| rutz::shared_ptr< std::istream > | openMaybeCompressedFile (const std::string &fname) |
| open a (possibly-compressed) file for reading | |
| void | splitPath (const std::string &fname, std::string &path, std::string &file) |
| split a path into a directory prefix (if any) and a filename | |
| void | makeDirectory (const std::string &dirname) |
| mkdir the given directory | |
| bool | isDirectory (const char *fname) |
| Returns true if fname refers to a directory. | |
| bool | isDirectory (const struct dirent *dirp) |
| Returns true if dirp refers to a directory. | |
| ushort | lockFile (const int fd, struct flock &fl) |
| Use fcntl to set and unset advisory locks on a file. | |
| ushort | unlockFile (const int fd, struct flock &fl) |
| Use fcntl to set and unset advisory locks on a file. | |
| ushort | lockFile (const std::string fileName, int &fd, struct flock &fl) |
| lock a file by name | |
| ushort | unlockFile (const std::string fileName, const int fd, struct flock &fl) |
| unlock a file and close | |
|
|
get the filename extension, INCLUDING the dot (e.g. ".jpg") returns an empty string if there is no extension on the filename Definition at line 95 of file FileUtil.C. |
|
||||||||||||
|
case-INsensitive check of whether str ends with ext
Definition at line 84 of file FileUtil.C. Referenced by addFileExtension(), getStimulusType(), hasMatchingExtension(), aux::is_img_file(), UcbMpegOutputStream::makeEncoder(), makeWriter(), and openMaybeCompressedFile(). |
|
|
Returns true if dirp refers to a directory. If dirent::d_type is available, use that; otherwise fall back to using a stat() call. Definition at line 209 of file FileUtil.C. References isDirectory(). |
|
|
Returns true if fname refers to a directory. Returns false in any other case (e.g., fname refers to a regular file, or refers to no file at all, etc.) Definition at line 195 of file FileUtil.C. Referenced by isDirectory(). |
|
||||||||||||||||
|
lock a file by name
Definition at line 259 of file FileUtil.C. References lockFile(). |
|
||||||||||||
|
Use fcntl to set and unset advisory locks on a file. You must include stdio.h, fcntl.h, cerrno and cstdio fl is of the type struct flock. This function is provided since fcntl is kind of weird to set and unset. Also, fcntl locks are different from flock locks for instance linux apache will only check fcntl based locks Definition at line 222 of file FileUtil.C. Referenced by lockFile(). |
|
|
mkdir the given directory Not an error if the directory already exists, but it is an error if a file (not a directory) exists with the given name. Definition at line 177 of file FileUtil.C. References LFATAL. Referenced by submain(), and Context::testFrame(). |
|
||||||||||||
|
get the filename extension, EXCLUDING the dot (e.g., "jpg") returns an empty string if there is no extension on the filename
Definition at line 107 of file FileUtil.C. References base. Referenced by dummy_namespace_to_avoid_gcc411_bug_YuvParser_C::getVideoFileInfoFromFilename(), and MrawvDecoder::MrawvDecoder(). |
|
|
open a (possibly-compressed) file for reading If the filename ends in ".gz", then the file is assumed to be gzip-compressed (likewise, ".bz2" implies bzip2-compressed), and the returned istream object will transparently decompressed. Otherwise, the file will be assumed to be uncompressed. If the file cannot be opened, an exception will be thrown. Definition at line 139 of file FileUtil.C. References hasExtension(), rutz::ibzip2open(), rutz::igzopen(), LFATAL, and rutz::make_shared(). |
|
||||||||||||||||
|
split a path into a directory prefix (if any) and a filename the directory prefix will be empty if there are no path separators ('/') in the path e.g. splitting "foo/bar.mpg" would give "foo/" and "bar.mpg" Definition at line 160 of file FileUtil.C. Referenced by playlist::purge(), and submain(). |
|
||||||||||||
|
Like fopen(fname, "w"), with some special cases.
Definition at line 55 of file FileUtil.C. References LFATAL. Referenced by addNoise(), StatsOutputSeries::Impl::openFile(), and HashOutputSeries::Impl::openFile(). |
|
||||||||||||||||
|
unlock a file and close
Definition at line 266 of file FileUtil.C. References unlockFile(). |
|
||||||||||||
|
Use fcntl to set and unset advisory locks on a file.
Definition at line 244 of file FileUtil.C. Referenced by unlockFile(). |
1.4.4