1e9191cc2SJohn Scipione/* 2b885e90eSJohn Scipione * Copyright 2009-2014 Haiku, Inc. All rights reserved. 3e9191cc2SJohn Scipione * Distributed under the terms of the MIT License. 4e9191cc2SJohn Scipione * 5e9191cc2SJohn Scipione * Authors: 6e9191cc2SJohn Scipione * Tyler Dauwalder 7e9191cc2SJohn Scipione * John Scipione, jscipione@gmail.com 8e9191cc2SJohn Scipione * Ingo Weinhold, bonefish@users.sf.net 9e9191cc2SJohn Scipione * 10e9191cc2SJohn Scipione * Corresponds to: 11b885e90eSJohn Scipione * headers/os/storage/File.h hrev47402 12b885e90eSJohn Scipione * src/kits/storage/File.cpp hrev47402 13e9191cc2SJohn Scipione */ 14e9191cc2SJohn Scipione 15e9191cc2SJohn Scipione 16e9191cc2SJohn Scipione/*! 17e9191cc2SJohn Scipione \file File.h 18820dca4dSJohn Scipione \ingroup storage 19820dca4dSJohn Scipione \ingroup libbe 20ea468b98SJohn Scipione \brief Provides the BFile class. 21e9191cc2SJohn Scipione*/ 22e9191cc2SJohn Scipione 23e9191cc2SJohn Scipione 24e9191cc2SJohn Scipione/*! 25e9191cc2SJohn Scipione \class BFile 26e9191cc2SJohn Scipione \ingroup storage 27e9191cc2SJohn Scipione \ingroup libbe 28e9191cc2SJohn Scipione \brief Provides the ability to read and write the data of a file. 29e9191cc2SJohn Scipione 30e9191cc2SJohn Scipione The file is automatically opened when you initialize a BFile and is 31e9191cc2SJohn Scipione automatically closed when you re-initialize or destroy the object. 32e9191cc2SJohn Scipione 33e9191cc2SJohn Scipione Symbolic links are automatically transversed by opening a BFile. 34e9191cc2SJohn Scipione The node that the BFile ends up opening will be the file or directory 35e9191cc2SJohn Scipione that the link points to, not the symbolic link file itself. 36b885e90eSJohn Scipione 37b885e90eSJohn Scipione \since BeOS R3 38e9191cc2SJohn Scipione*/ 39e9191cc2SJohn Scipione 40e9191cc2SJohn Scipione 41e9191cc2SJohn Scipione/*! 42e9191cc2SJohn Scipione \fn BFile::BFile() 43e9191cc2SJohn Scipione \brief Creates an uninitialized BFile object. 44e9191cc2SJohn Scipione 45e9191cc2SJohn Scipione Should be followed by a call to one of the SetTo() methods, or an 46e9191cc2SJohn Scipione assignment: 47e9191cc2SJohn Scipione - SetTo(const entry_ref* ref, uint32 openMode) 48e9191cc2SJohn Scipione - SetTo(const BEntry* entry, uint32 openMode) 49e9191cc2SJohn Scipione - SetTo(const char* path, uint32 openMode) 50e9191cc2SJohn Scipione - SetTo(const BDirectory* dir, const char* path, uint32 openMode) 51e9191cc2SJohn Scipione - operator=(const BFile &file) 52b885e90eSJohn Scipione 53b885e90eSJohn Scipione \since BeOS R3 54e9191cc2SJohn Scipione*/ 55e9191cc2SJohn Scipione 56e9191cc2SJohn Scipione 57e9191cc2SJohn Scipione/*! 58e9191cc2SJohn Scipione \fn BFile::BFile(const BFile& file) 59e9191cc2SJohn Scipione \brief Creates a copy of the supplied BFile. 60e9191cc2SJohn Scipione 61e9191cc2SJohn Scipione If \a file is uninitialized, the newly constructed BFile will be too. 62e9191cc2SJohn Scipione 63e9191cc2SJohn Scipione \param file The BFile object to be copied. 64b885e90eSJohn Scipione 65b885e90eSJohn Scipione \since BeOS R3 66e9191cc2SJohn Scipione*/ 67e9191cc2SJohn Scipione 68e9191cc2SJohn Scipione 69e9191cc2SJohn Scipione/*! 70e9191cc2SJohn Scipione \fn BFile::BFile(const entry_ref* ref, uint32 openMode) 71e9191cc2SJohn Scipione \brief Creates a BFile and initializes it to the file referred to by 72e9191cc2SJohn Scipione the supplied entry_ref and according to the specified open mode. 73e9191cc2SJohn Scipione 74e9191cc2SJohn Scipione \param ref The entry_ref referring to the file. 75e9191cc2SJohn Scipione \param openMode The mode in which the file should be opened. 76e9191cc2SJohn Scipione 77e9191cc2SJohn Scipione \see SetTo(const entry_ref* ref, uint32 openMode) 78b885e90eSJohn Scipione 79b885e90eSJohn Scipione \since BeOS R3 80e9191cc2SJohn Scipione*/ 81e9191cc2SJohn Scipione 82e9191cc2SJohn Scipione 83e9191cc2SJohn Scipione/*! 84e9191cc2SJohn Scipione \fn BFile::BFile(const BEntry* entry, uint32 openMode) 85e9191cc2SJohn Scipione \brief Creates a BFile and initializes it to the file referred to by 86e9191cc2SJohn Scipione the supplied BEntry and according to the specified open mode. 87e9191cc2SJohn Scipione 88e9191cc2SJohn Scipione \param entry The BEntry referring to the file. 89e9191cc2SJohn Scipione \param openMode The mode in which the file should be opened. 90e9191cc2SJohn Scipione 91e9191cc2SJohn Scipione \see SetTo(const BEntry* entry, uint32 openMode) 92b885e90eSJohn Scipione 93b885e90eSJohn Scipione \since BeOS R3 94e9191cc2SJohn Scipione*/ 95e9191cc2SJohn Scipione 96e9191cc2SJohn Scipione 97e9191cc2SJohn Scipione/*! 98e9191cc2SJohn Scipione \fn BFile::BFile(const char* path, uint32 openMode) 99e9191cc2SJohn Scipione \brief Creates a BFile and initializes it to the file referred to by 100e9191cc2SJohn Scipione the supplied path name and according to the specified open mode. 101e9191cc2SJohn Scipione 102e9191cc2SJohn Scipione \param path The file's path name. 103e9191cc2SJohn Scipione \param openMode The mode in which the file should be opened. 104e9191cc2SJohn Scipione 105e9191cc2SJohn Scipione \see SetTo(const char* path, uint32 openMode) 106b885e90eSJohn Scipione 107b885e90eSJohn Scipione \since BeOS R3 108e9191cc2SJohn Scipione*/ 109e9191cc2SJohn Scipione 110e9191cc2SJohn Scipione 111e9191cc2SJohn Scipione/*! 112e9191cc2SJohn Scipione \fn BFile::BFile(const BDirectory *dir, const char* path, uint32 openMode) 113e9191cc2SJohn Scipione \brief Creates a BFile and initializes it to the file referred to by 114e9191cc2SJohn Scipione the supplied path name relative to the specified BDirectory and 115e9191cc2SJohn Scipione according to the specified open mode. 116e9191cc2SJohn Scipione 117e9191cc2SJohn Scipione \param dir The BDirectory, relative to which the file's path name is 118e9191cc2SJohn Scipione given. 119e9191cc2SJohn Scipione \param path The file's path name relative to \a dir. 120e9191cc2SJohn Scipione \param openMode The mode in which the file should be opened. 121e9191cc2SJohn Scipione 122e9191cc2SJohn Scipione \see SetTo(const BDirectory* dir, const char* path, uint32 openMode) 123b885e90eSJohn Scipione 124b885e90eSJohn Scipione \since BeOS R3 125e9191cc2SJohn Scipione*/ 126e9191cc2SJohn Scipione 127e9191cc2SJohn Scipione 128e9191cc2SJohn Scipione/*! 129e9191cc2SJohn Scipione \fn BFile::~BFile() 130e9191cc2SJohn Scipione \brief Destroys the BFile object and frees all allocated resources. 131e9191cc2SJohn Scipione 132e9191cc2SJohn Scipione If the file is properly initialized, the file descriptor is closed. 133b885e90eSJohn Scipione 134b885e90eSJohn Scipione \since BeOS R3 135e9191cc2SJohn Scipione*/ 136e9191cc2SJohn Scipione 137e9191cc2SJohn Scipione 138e9191cc2SJohn Scipione/*! 139e9191cc2SJohn Scipione \fn status_t BFile::SetTo(const entry_ref* ref, uint32 openMode) 140e9191cc2SJohn Scipione \brief Re-initializes the BFile to the file referred to by the 141e9191cc2SJohn Scipione supplied entry_ref and according to the specified open mode. 142e9191cc2SJohn Scipione 143e9191cc2SJohn Scipione \param ref The entry_ref referring to the file. 144e9191cc2SJohn Scipione \param openMode The mode in which the file should be opened 145e9191cc2SJohn Scipione \a openMode must be a bitwise or of exactly one of the flags. 146e9191cc2SJohn Scipione - \c B_READ_ONLY: The file is opened read only. 147e9191cc2SJohn Scipione - \c B_WRITE_ONLY: The file is opened write only. 148e9191cc2SJohn Scipione - \c B_READ_WRITE: The file is opened for random read/write access. 149e9191cc2SJohn Scipione and any number of the flags 150b885e90eSJohn Scipione - \c B_CREATE_FILE: A new file will be created, if it does not 151b885e90eSJohn Scipione already exist. 152e9191cc2SJohn Scipione - \c B_FAIL_IF_EXISTS: If the file does already exist and 153e9191cc2SJohn Scipione \c B_CREATE_FILE is set, SetTo() fails. 154b885e90eSJohn Scipione - \c B_ERASE_FILE: An already existing file is truncated to zero 155b885e90eSJohn Scipione size. 156e9191cc2SJohn Scipione - \c B_OPEN_AT_END: Seek() to the end of the file after opening. 157e9191cc2SJohn Scipione 158e9191cc2SJohn Scipione \returns A status code. 159e9191cc2SJohn Scipione \retval B_OK Everything went fine. 160e9191cc2SJohn Scipione \retval B_BAD_VALUE \c NULL \a ref or bad \a openMode. 161e9191cc2SJohn Scipione \retval B_ENTRY_NOT_FOUND File not found or failed to create file. 162e9191cc2SJohn Scipione \retval B_FILE_EXISTS File exists and \c B_FAIL_IF_EXISTS was passed. 163e9191cc2SJohn Scipione \retval B_PERMISSION_DENIED File permissions didn't allow operation. 164e9191cc2SJohn Scipione \retval B_NO_MEMORY Insufficient memory for operation. 165e9191cc2SJohn Scipione \retval B_LINK_LIMIT Indicates a cyclic loop within the file system. 166e9191cc2SJohn Scipione \retval B_BUSY A node was busy. 167e9191cc2SJohn Scipione \retval B_FILE_ERROR A general file error. 168e9191cc2SJohn Scipione \retval B_NO_MORE_FDS The application has run out of file descriptors. 169b885e90eSJohn Scipione 170b885e90eSJohn Scipione \since BeOS R3 171e9191cc2SJohn Scipione*/ 172e9191cc2SJohn Scipione 173e9191cc2SJohn Scipione 174e9191cc2SJohn Scipione/*! 175e9191cc2SJohn Scipione \fn status_t BFile::SetTo(const BEntry* entry, uint32 openMode) 176e9191cc2SJohn Scipione \brief Re-initializes the BFile to the file referred to by the 177e9191cc2SJohn Scipione supplied BEntry and according to the specified open mode. 178e9191cc2SJohn Scipione 179e9191cc2SJohn Scipione \param entry the BEntry referring to the file 180e9191cc2SJohn Scipione \param openMode the mode in which the file should be opened 181e9191cc2SJohn Scipione 182e9191cc2SJohn Scipione \returns A status code. 183e9191cc2SJohn Scipione \retval B_OK Everything went fine. 184e9191cc2SJohn Scipione \retval B_BAD_VALUE \c NULL \a entry or bad \a openMode. 185e9191cc2SJohn Scipione \retval B_ENTRY_NOT_FOUND File not found or failed to create file. 186e9191cc2SJohn Scipione \retval B_FILE_EXISTS File exists and \c B_FAIL_IF_EXISTS was passed. 187e9191cc2SJohn Scipione \retval B_PERMISSION_DENIED File permissions didn't allow operation. 188e9191cc2SJohn Scipione \retval B_NO_MEMORY Insufficient memory for operation. 189e9191cc2SJohn Scipione \retval B_LINK_LIMIT Indicates a cyclic loop within the file system. 190e9191cc2SJohn Scipione \retval B_BUSY A node was busy. 191e9191cc2SJohn Scipione \retval B_FILE_ERROR A general file error. 192e9191cc2SJohn Scipione \retval B_NO_MORE_FDS The application has run out of file descriptors. 193e9191cc2SJohn Scipione 194e9191cc2SJohn Scipione \todo Implemented using SetTo(entry_ref*, uint32). Check, if necessary 195e9191cc2SJohn Scipione to re-implement! 196b885e90eSJohn Scipione 197b885e90eSJohn Scipione \since BeOS R3 198e9191cc2SJohn Scipione*/ 199e9191cc2SJohn Scipione 200e9191cc2SJohn Scipione 201e9191cc2SJohn Scipione/*! 202e9191cc2SJohn Scipione \fn status_t BFile::SetTo(const char* path, uint32 openMode) 203e9191cc2SJohn Scipione \brief Re-initializes the BFile to the file referred to by the 204e9191cc2SJohn Scipione supplied path name and according to the specified open mode. 205e9191cc2SJohn Scipione 206e9191cc2SJohn Scipione \param path The file's path name. 207e9191cc2SJohn Scipione \param openMode The mode in which the file should be opened. 208e9191cc2SJohn Scipione 209e9191cc2SJohn Scipione \returns A status code. 210e9191cc2SJohn Scipione \retval B_OK Everything went fine. 211e9191cc2SJohn Scipione \retval B_BAD_VALUE \c NULL \a path or bad \a openMode. 212e9191cc2SJohn Scipione \retval B_ENTRY_NOT_FOUND File not found or failed to create file. 213e9191cc2SJohn Scipione \retval B_FILE_EXISTS File exists and \c B_FAIL_IF_EXISTS was passed. 214e9191cc2SJohn Scipione \retval B_PERMISSION_DENIED File permissions didn't allow operation. 215e9191cc2SJohn Scipione \retval B_NO_MEMORY Insufficient memory for operation. 216e9191cc2SJohn Scipione \retval B_LINK_LIMIT Indicates a cyclic loop within the file system. 217e9191cc2SJohn Scipione \retval B_BUSY A node was busy. 218e9191cc2SJohn Scipione \retval B_FILE_ERROR A general file error. 219e9191cc2SJohn Scipione \retval B_NO_MORE_FDS The application has run out of file descriptors. 220b885e90eSJohn Scipione 221b885e90eSJohn Scipione \since BeOS R3 222e9191cc2SJohn Scipione*/ 223e9191cc2SJohn Scipione 224e9191cc2SJohn Scipione 225e9191cc2SJohn Scipione/*! 226e9191cc2SJohn Scipione \fn status_t BFile::SetTo(const BDirectory* dir, const char* path, 227e9191cc2SJohn Scipione uint32 openMode) 228e9191cc2SJohn Scipione \brief Re-initializes the BFile to the file referred to by the 229e9191cc2SJohn Scipione supplied path name relative to the specified BDirectory and 230e9191cc2SJohn Scipione according to the specified open mode. 231e9191cc2SJohn Scipione 232e9191cc2SJohn Scipione \param dir The BDirectory, relative to which the file's path name is 233e9191cc2SJohn Scipione given. 234e9191cc2SJohn Scipione \param path The file's path name relative to \a dir. 235e9191cc2SJohn Scipione \param openMode The mode in which the file should be opened. 236e9191cc2SJohn Scipione 237e9191cc2SJohn Scipione \returns A status code. 238e9191cc2SJohn Scipione \retval B_OK Everything went fine. 239e9191cc2SJohn Scipione \retval B_BAD_VALUE \c NULL \a dir or \a path or bad \a openMode. 240e9191cc2SJohn Scipione \retval B_ENTRY_NOT_FOUND File not found or failed to create file. 241e9191cc2SJohn Scipione \retval B_FILE_EXISTS File exists and \c B_FAIL_IF_EXISTS was passed. 242e9191cc2SJohn Scipione \retval B_PERMISSION_DENIED File permissions didn't allow operation. 243e9191cc2SJohn Scipione \retval B_NO_MEMORY Insufficient memory for operation. 244e9191cc2SJohn Scipione \retval B_LINK_LIMIT Indicates a cyclic loop within the file system. 245e9191cc2SJohn Scipione \retval B_BUSY A node was busy. 246e9191cc2SJohn Scipione \retval B_FILE_ERROR A general file error. 247e9191cc2SJohn Scipione \retval B_NO_MORE_FDS The application has run out of file descriptors. 248e9191cc2SJohn Scipione 249e9191cc2SJohn Scipione \todo Implemented using SetTo(BEntry*, uint32). Check, if necessary 250e9191cc2SJohn Scipione to re-implement! 251b885e90eSJohn Scipione 252b885e90eSJohn Scipione \since BeOS R3 253e9191cc2SJohn Scipione*/ 254e9191cc2SJohn Scipione 255e9191cc2SJohn Scipione 256e9191cc2SJohn Scipione/*! 257e9191cc2SJohn Scipione \fn bool BFile::IsReadable() const 258e9191cc2SJohn Scipione \brief Reports whether or not the file is readable. 259e9191cc2SJohn Scipione 260e9191cc2SJohn Scipione \return 261e9191cc2SJohn Scipione - \c true, if the BFile has been initialized properly and the file has 262e9191cc2SJohn Scipione been been opened for reading, 263e9191cc2SJohn Scipione - \c false, otherwise. 264b885e90eSJohn Scipione 265b885e90eSJohn Scipione \since BeOS R3 266e9191cc2SJohn Scipione*/ 267e9191cc2SJohn Scipione 268e9191cc2SJohn Scipione 269e9191cc2SJohn Scipione/*! 270e9191cc2SJohn Scipione \fn bool BFile::IsWritable() const 271e9191cc2SJohn Scipione \brief Reports whether or not the file is writable. 272e9191cc2SJohn Scipione 273e9191cc2SJohn Scipione \return 274e9191cc2SJohn Scipione - \c true, if the BFile has been initialized properly and the file has 275e9191cc2SJohn Scipione been opened for writing, 276e9191cc2SJohn Scipione - \c false, otherwise. 277b885e90eSJohn Scipione 278b885e90eSJohn Scipione \since BeOS R3 279e9191cc2SJohn Scipione*/ 280e9191cc2SJohn Scipione 281e9191cc2SJohn Scipione 282e9191cc2SJohn Scipione/*! 283*a8081885SNiels Sascha Reedijk \fn ssize_t BFile::Read(void* buffer, size_t size) 284e9191cc2SJohn Scipione \brief Reads a number of bytes from the file into a buffer. 285e9191cc2SJohn Scipione 286e9191cc2SJohn Scipione \param buffer The buffer the data from the file shall be written to. 287e9191cc2SJohn Scipione \param size The number of bytes that shall be read. 288e9191cc2SJohn Scipione 289e9191cc2SJohn Scipione \returns The number of bytes read or an error code. 290b885e90eSJohn Scipione 291b885e90eSJohn Scipione \since BeOS R3 292e9191cc2SJohn Scipione*/ 293e9191cc2SJohn Scipione 294e9191cc2SJohn Scipione 295e9191cc2SJohn Scipione/*! 296e9191cc2SJohn Scipione \fn ssize_t BFile::ReadAt(off_t location, void* buffer, size_t size) 297e9191cc2SJohn Scipione \brief Reads a number of bytes from a certain position within the file 298e9191cc2SJohn Scipione into a buffer. 299e9191cc2SJohn Scipione 300e9191cc2SJohn Scipione \param location The position (in bytes) within the file from which the 301e9191cc2SJohn Scipione data shall be read. 302e9191cc2SJohn Scipione \param buffer The buffer the data from the file shall be written to. 303e9191cc2SJohn Scipione \param size The number of bytes that shall be read. 304e9191cc2SJohn Scipione 305e9191cc2SJohn Scipione \returns The number of bytes read or an error code. 306b885e90eSJohn Scipione 307b885e90eSJohn Scipione \since BeOS R3 308e9191cc2SJohn Scipione*/ 309e9191cc2SJohn Scipione 310e9191cc2SJohn Scipione 311e9191cc2SJohn Scipione/*! 312e9191cc2SJohn Scipione \fn ssize_t BFile::Write(const void* buffer, size_t size) 313e9191cc2SJohn Scipione \brief Writes a number of bytes from a buffer into the file. 314e9191cc2SJohn Scipione 315e9191cc2SJohn Scipione \param buffer The buffer containing the data to be written to the file. 316e9191cc2SJohn Scipione \param size The number of bytes that shall be written. 317e9191cc2SJohn Scipione 318e9191cc2SJohn Scipione \returns The number of bytes actually written or an error code. 319b885e90eSJohn Scipione 320b885e90eSJohn Scipione \since BeOS R3 321e9191cc2SJohn Scipione*/ 322e9191cc2SJohn Scipione 323e9191cc2SJohn Scipione 324e9191cc2SJohn Scipione/*! 325e9191cc2SJohn Scipione \fn ssize_t BFile::WriteAt(off_t location, const void* buffer, size_t size) 326b885e90eSJohn Scipione \brief Writes a number of bytes from a buffer at a certain position 327e9191cc2SJohn Scipione into the file. 328e9191cc2SJohn Scipione 329e9191cc2SJohn Scipione \param location The position (in bytes) within the file at which the data 330e9191cc2SJohn Scipione shall be written. 331e9191cc2SJohn Scipione \param buffer The buffer containing the data to be written to the file. 332e9191cc2SJohn Scipione \param size The number of bytes that shall be written. 333e9191cc2SJohn Scipione 334e9191cc2SJohn Scipione \returns The number of bytes actually written or an error code. 335b885e90eSJohn Scipione 336b885e90eSJohn Scipione \since BeOS R3 337e9191cc2SJohn Scipione*/ 338e9191cc2SJohn Scipione 339e9191cc2SJohn Scipione 340e9191cc2SJohn Scipione/*! 341e9191cc2SJohn Scipione \fn off_t BFile::Seek(off_t offset, uint32 seekMode) 342e9191cc2SJohn Scipione \brief Seeks to another read/write position within the file. 343e9191cc2SJohn Scipione 344e9191cc2SJohn Scipione It is allowed to seek past the end of the file. A subsequent call to 345e9191cc2SJohn Scipione Write() will pad the file with undefined data. Seeking before the 346e9191cc2SJohn Scipione beginning of the file will fail and the behavior of subsequent Read() 347e9191cc2SJohn Scipione or Write() invocations will be undefined. 348e9191cc2SJohn Scipione 349e9191cc2SJohn Scipione \param offset New read/write position, depending on \a seekMode relative 350e9191cc2SJohn Scipione to the beginning or the end of the file or the current position. 351e9191cc2SJohn Scipione \param seekMode 352b885e90eSJohn Scipione - \c SEEK_SET: move relative to the beginning of the file. 353b885e90eSJohn Scipione - \c SEEK_CUR: move relative to the current position. 354b885e90eSJohn Scipione - \c SEEK_END: move relative to the end of the file. 355e9191cc2SJohn Scipione 356e9191cc2SJohn Scipione \returns The new read/write position relative to the beginning of the 357e9191cc2SJohn Scipione file or an error code. 358e9191cc2SJohn Scipione \retval B_ERROR Trying to seek before the beginning of the file. 359e9191cc2SJohn Scipione \retval B_FILE_ERROR The file is not properly initialized. 360b885e90eSJohn Scipione 361b885e90eSJohn Scipione \since BeOS R3 362e9191cc2SJohn Scipione*/ 363e9191cc2SJohn Scipione 364e9191cc2SJohn Scipione 365e9191cc2SJohn Scipione/*! 366e9191cc2SJohn Scipione \fn off_t BFile::Position() const 367e9191cc2SJohn Scipione \brief Gets the current read/write position within the file. 368e9191cc2SJohn Scipione 369e9191cc2SJohn Scipione \returns The current read/write position relative to the beginning of the 370e9191cc2SJohn Scipione file or an error code. 371e9191cc2SJohn Scipione \retval B_ERROR After a Seek() before the beginning of the file. 372e9191cc2SJohn Scipione \retval B_FILE_ERROR The file has not been initialized. 373b885e90eSJohn Scipione 374b885e90eSJohn Scipione \since BeOS R3 375e9191cc2SJohn Scipione*/ 376e9191cc2SJohn Scipione 377e9191cc2SJohn Scipione 378e9191cc2SJohn Scipione/*! 379e9191cc2SJohn Scipione \fn status_t BFile::SetSize(off_t size) 380e9191cc2SJohn Scipione \brief Sets the size of the file. 381e9191cc2SJohn Scipione 382e9191cc2SJohn Scipione If the file is shorter than \a size bytes it will be padded with 383e9191cc2SJohn Scipione unspecified data to the requested size. If it is larger, it will be 384e9191cc2SJohn Scipione truncated. 385e9191cc2SJohn Scipione 386e9191cc2SJohn Scipione \note There's no problem with setting the size of a BFile opened in 387e9191cc2SJohn Scipione \c B_READ_ONLY mode, unless the file resides on a read only volume. 388e9191cc2SJohn Scipione 389e9191cc2SJohn Scipione \param size The new file size. 390e9191cc2SJohn Scipione 391e9191cc2SJohn Scipione \returns A status code. 392e9191cc2SJohn Scipione \retval B_OK Everything went fine. 393e9191cc2SJohn Scipione \retval B_NOT_ALLOWED Trying to set the size of a file on a read only 394e9191cc2SJohn Scipione volume. 395e9191cc2SJohn Scipione \retval B_DEVICE_FULL There's not enough space left on the volume. 396b885e90eSJohn Scipione 397b885e90eSJohn Scipione \since BeOS R3 398e9191cc2SJohn Scipione*/ 399e9191cc2SJohn Scipione 400e9191cc2SJohn Scipione 401e9191cc2SJohn Scipione/*! 402e9191cc2SJohn Scipione \fn status_t BFile::GetSize(off_t* size) const 403e9191cc2SJohn Scipione \brief Gets the size of the file. 404e9191cc2SJohn Scipione 405e9191cc2SJohn Scipione \param size The file size to fill out. 406e9191cc2SJohn Scipione 407e9191cc2SJohn Scipione \returns A status code. 408e9191cc2SJohn Scipione 409e9191cc2SJohn Scipione \see BStatable::GetSize() 410b885e90eSJohn Scipione 411b885e90eSJohn Scipione \since BeOS R3 412e9191cc2SJohn Scipione*/ 413e9191cc2SJohn Scipione 414e9191cc2SJohn Scipione 415e9191cc2SJohn Scipione/*! 416e9191cc2SJohn Scipione \fn BFile& BFile::operator=(const BFile &file) 417e9191cc2SJohn Scipione \brief Assigns another BFile to this BFile. 418e9191cc2SJohn Scipione 419e9191cc2SJohn Scipione If the other BFile is uninitialized, this one will be too. Otherwise it 420e9191cc2SJohn Scipione will refer to the same file using the same mode, unless an error occurs. 421e9191cc2SJohn Scipione 422e9191cc2SJohn Scipione \param file The original BFile to assign from. 423e9191cc2SJohn Scipione 424e9191cc2SJohn Scipione \returns A reference to the assigned BFile. 425e9191cc2SJohn Scipione 426b885e90eSJohn Scipione \since BeOS R3 427e9191cc2SJohn Scipione*/ 428