/usr/include/BALL/SYSTEM/file.iC is in libball1.4-dev 1.4.1+20111206-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | // -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
BALL_INLINE
void File::clear()
{
File::close();
name_ = "";
}
BALL_INLINE
const String& File::getName() const
{
return name_;
}
BALL_INLINE
void File::setName(const String& name)
{
File::close();
name_ = name;
FileSystem::canonizePath(name_);
}
BALL_INLINE
File::OpenMode File::getOpenMode() const
{
return open_mode_;
}
BALL_INLINE
File::Type File::getType(bool trace_link) const
{
return File::getType(name_, trace_link);
}
BALL_INLINE
bool File::copyTo(const String& destination_name, Size buffer_size)
{
return File::copy(name_, destination_name, buffer_size);
}
BALL_INLINE
bool File::remove(String name)
{
FileSystem::canonizePath(name);
#ifdef BALL_COMPILER_MSVC
return (::_unlink(name.c_str()) == 0);
#else
return (::unlink(name.c_str()) == 0);
#endif
}
BALL_INLINE
bool File::remove()
{
#ifdef BALL_COMPILER_MSVC
File::close();
#endif
return File::remove(name_);
}
BALL_INLINE
bool File::move(const String& source_name, const String& destination_name)
{
if (File::copy(source_name, destination_name))
{
return File::remove(source_name);
}
return false;
}
BALL_INLINE
bool File::moveTo(const String& destination_name)
{
#ifdef BALL_COMPILER_MSVC
File::close();
#endif
if (File::move(name_, destination_name))
{
name_ = destination_name;
File::reopen();
return true;
}
return false;
}
BALL_INLINE
bool File::isAccessible(String name)
{
FileSystem::canonizePath(name);
#ifdef BALL_COMPILER_MSVC
return (::_access(name.c_str(),F_OK) == 0);
#else
return (::access(name.c_str(), F_OK) == 0);
#endif
}
BALL_INLINE
bool File::isAccessible() const
{
return File::isAccessible(name_);
}
BALL_INLINE
bool File::rename(String old_path, String new_path)
{
FileSystem::canonizePath(old_path);
FileSystem::canonizePath(new_path);
if (!isAccessible(old_path))
{
throw (Exception::FileNotFound(__FILE__, __LINE__, old_path));
}
#ifdef BALL_COMPILER_MSVC
if(old_path==new_path) return true;
#endif
return (::rename(old_path.c_str(), new_path.c_str()) == 0);
}
BALL_INLINE
bool File::renameTo(const String& new_path)
{
#ifdef BALL_COMPILER_MSVC
File::close();
#endif
if (!File::rename(name_, new_path))
{
#ifdef BALL_COMPILER_MSVC
File::reopen();
#endif
return false;
}
name_ = new_path;
#ifdef BALL_COMPILER_MSVC
File::reopen();
#endif
return true;
}
BALL_INLINE
bool File::truncate(String path, Size size)
{
if (!isAccessible(path))
{
throw (Exception::FileNotFound(__FILE__, __LINE__, path));
}
FileSystem::canonizePath(path);
#ifdef BALL_COMPILER_MSVC
int fh = _open(path.c_str(), _O_RDWR | _O_CREAT, _S_IREAD | _S_IWRITE );
int result = _chsize(fh, (long)size);
_close(fh);
return (result == 0);
#else
return (::truncate(path.c_str(), (long)size) == 0);
#endif
}
BALL_INLINE
bool File::truncate(Size size)
{
return File::truncate(name_, size);
}
BALL_INLINE
bool File::operator == (const File &file) const
{
return (name_ == file.name_);
}
BALL_INLINE
bool File::operator != (const File &file) const
{
return (name_ != file.name_);
}
BALL_INLINE
bool File::isValid() const
{
return (getName() != "" && ((File*)this)->std::fstream::good() );
}
BALL_INLINE
bool File::isOpen() const
{
return is_open_;
}
BALL_INLINE
bool File::isClosed() const
{
return !is_open_;
}
BALL_INLINE
bool File::isCanonized() const
{
if (!isAccessible()) throw(Exception::FileNotFound(__FILE__, __LINE__, name_));
String canonized_name(name_);
FileSystem::canonizePath(canonized_name);
return (name_ == canonized_name);
}
BALL_INLINE
bool File::isReadable(String name)
{
if (!File::isAccessible(name)) throw(Exception::FileNotFound(__FILE__, __LINE__, name));
FileSystem::canonizePath(name);
return (::access(name.c_str(), R_OK) == 0);
}
BALL_INLINE
bool File::isReadable() const
{
return File::isReadable(name_);
}
BALL_INLINE
bool File::isWritable(String name)
{
if (!File::isAccessible(name)) throw(Exception::FileNotFound(__FILE__, __LINE__, name));
FileSystem::canonizePath(name);
return (::access(name.c_str(), W_OK) == 0);
}
BALL_INLINE
bool File::isWritable() const
{
return File::isWritable(name_);
}
BALL_INLINE
bool File::isExecutable(String name)
{
if (!isAccessible(name)) throw(Exception::FileNotFound(__FILE__, __LINE__, name));
FileSystem::canonizePath(name);
#ifdef BALL_COMPILER_MSVC
return false;
#else
return (::access(name.c_str(), X_OK) == 0);
#endif
}
BALL_INLINE
bool File::isExecutable() const
{
return File::isExecutable(name_);
}
BALL_INLINE
Size File::getSize(String name)
{
File tmp(name);
return tmp.getSize();
}
BALL_INLINE
std::fstream& File::getFileStream()
{
return *this;
}
BALL_INLINE
const String& File::getOriginalName() const
{
return original_name_;
}
|