libgit2/src/filelock.h
Vicent Marti bd0a51c0dd Add support for atomic file locking
The struct 'git_filelock' represents an atomically-locked
file, git-style.

Locked files can be modified atomically through the new file lock
interface:

int git_filelock_init(git_filelock *lock, const char *path);
int git_filelock_lock(git_filelock *lock, int append);
void git_filelock_unlock(git_filelock *lock);
int git_filelock_commit(git_filelock *lock);
int git_filelock_write(git_filelock *lock, const char *buffer, size_t length);

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-08-12 18:49:04 +02:00

24 lines
530 B
C

#ifndef INCLUDE_filelock_h__
#define INCLUDE_filelock_h__
#include "fileops.h"
struct git_filelock {
char path[GIT_PATH_MAX];
size_t path_length;
git_file file_lock;
int is_locked;
};
typedef struct git_filelock git_filelock;
int git_filelock_init(git_filelock *lock, const char *path);
int git_filelock_lock(git_filelock *lock, int append);
void git_filelock_unlock(git_filelock *lock);
int git_filelock_commit(git_filelock *lock);
int git_filelock_write(git_filelock *lock, const void *buffer, size_t length);
#endif