le_atomFile.h
Go to the documentation of this file.
11 * This API only supports regular files. Attempts to use this API on sockets, devices, etc. results17 * operation is performed or the operation fails. Any unclean reboot or power-cut should not lead to18 * corruption or inconsistency of the file. Also when a process is performing an atomic write on a22 * Use @c le_atomFile_Open() to open a file for atomic access. This API uses @ref c_flock_cooperative32 * Writing on the file descriptors obtained by this API same as writing to regular file descriptor.33 * That means, any write to a file descriptor using this API doesn't ensure that data is transferred150 * The functions @c le_atomFile_OpenStream() and @c le_atomFile_CreateStream() can be used to obtain151 * a file stream for atomic operation. @c le_atomFile_CloseStream() is used to commit all changes152 * to disk and close the stream. @c le_atomFile_CancelStream() is used to discard all changes and154 * le_atomFile_Close() and le_atomFile_Cancel() except that works on file streams rather than file160 * le_atomFile_CreateStream() and le_atomFile_Delete() always block if there is an incompatible lock162 * le_atomFile_TryOpenStream(), le_atomFile_TryCreateStream() and le_atomFile_TryDelete() are their194 * closing APIs (i.e. le_atomFile_Close(), le_atomFile_CloseStream() etc.). This is illustrated in249 //--------------------------------------------------------------------------------------------------261 //--------------------------------------------------------------------------------------------------266 * Parameter accessMode specifies the lock to be applied on the file (read lock will be applied for280 //--------------------------------------------------------------------------------------------------288 //--------------------------------------------------------------------------------------------------292 * If the file does not exist it will be created with the file permissions specified in the argument293 * permissions (modified by the process's umask). Refer to the POSIX function open(2) for details299 * Parameter accessMode specifies the lock to be applied on the file (read lock will be applied for302 * This is a blocking call. It will block until it can create and open the target file with specified313 //--------------------------------------------------------------------------------------------------324 //--------------------------------------------------------------------------------------------------326 * Same as @c le_atomFile_Open() except that it is non-blocking function and it will fail and return338 //--------------------------------------------------------------------------------------------------346 //--------------------------------------------------------------------------------------------------360 //--------------------------------------------------------------------------------------------------370 //--------------------------------------------------------------------------------------------------374 //--------------------------------------------------------------------------------------------------381 //--------------------------------------------------------------------------------------------------383 * Commits all changes and closes the file descriptor. No need to close the file descriptor again if384 * this function returns error (i.e. file descriptor is closed in both success and error scenario).390 //--------------------------------------------------------------------------------------------------397 //--------------------------------------------------------------------------------------------------402 * Parameter accessMode specifies the lock to be applied on the file (read lock will be applied for420 //--------------------------------------------------------------------------------------------------430 //--------------------------------------------------------------------------------------------------434 * If the file does not exist it will be created with the file permissions specified in the argument435 * permissions (modified by the process's umask). Refer to the POSIX function open(2) for details441 * Parameter accessMode specifies the lock to be applied on the file (read lock will be applied for448 * - LE_DUPLICATE if the file already exists and LE_FLOCK_FAIL_IF_EXIST is specified in createMode.459 //--------------------------------------------------------------------------------------------------472 //--------------------------------------------------------------------------------------------------474 * Same as @c le_atomFile_OpenStream() except that it is non-blocking function and it will fail and490 //--------------------------------------------------------------------------------------------------499 //--------------------------------------------------------------------------------------------------501 * Same as @c le_atomFile_CreateStream() except that it is non-blocking function and it will fail505 * - LE_DUPLICATE if the file already exists and LE_FLOCK_FAIL_IF_EXIST is specified in createMode.517 //--------------------------------------------------------------------------------------------------528 //--------------------------------------------------------------------------------------------------532 //--------------------------------------------------------------------------------------------------539 //--------------------------------------------------------------------------------------------------541 * Commits all changes and closes the file stream. No need to close the file stream again if this548 //--------------------------------------------------------------------------------------------------555 //--------------------------------------------------------------------------------------------------557 * Atomically deletes a file. This function also ensures safe deletion of file (i.e. if any other558 * process/thread is using the file by acquiring file lock, it won't delete the file unless lock is566 //--------------------------------------------------------------------------------------------------573 //--------------------------------------------------------------------------------------------------584 //--------------------------------------------------------------------------------------------------le_result_t le_atomFile_Delete(const char *pathNamePtr)void le_atomFile_Cancel(int fd)int le_atomFile_TryCreate(const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_flock_CreateMode_t createMode, mode_t permissions)int le_atomFile_Create(const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_flock_CreateMode_t createMode, mode_t permissions)int le_atomFile_TryOpen(const char *pathNamePtr, le_flock_AccessMode_t accessMode)FILE * le_atomFile_OpenStream(const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_result_t *resultPtr)le_result_t le_atomFile_CloseStream(FILE *fileStreamPtr)FILE * le_atomFile_TryCreateStream(const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_flock_CreateMode_t createMode, mode_t permissions, le_result_t *resultPtr)le_result_t le_atomFile_TryDelete(const char *pathNamePtr)void le_atomFile_CancelStream(FILE *fileStreamPtr)le_result_t le_atomFile_Close(int fd)int le_atomFile_Open(const char *pathNamePtr, le_flock_AccessMode_t accessMode)FILE * le_atomFile_TryOpenStream(const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_result_t *resultPtr)FILE * le_atomFile_CreateStream(const char *pathNamePtr, le_flock_AccessMode_t accessMode, le_flock_CreateMode_t createMode, mode_t permissions, le_result_t *resultPtr)