1/* Copyright (C) 2007-2008 The Android Open Source Project 2** 3** This software is licensed under the terms of the GNU General Public 4** License version 2, as published by the Free Software Foundation, and 5** may be copied, distributed, and modified under those terms. 6** 7** This program is distributed in the hope that it will be useful, 8** but WITHOUT ANY WARRANTY; without even the implied warranty of 9** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10** GNU General Public License for more details. 11*/ 12 13#ifndef _ANDROID_UTILS_FILELOCK_H 14#define _ANDROID_UTILS_FILELOCK_H 15 16#include "android/utils/compiler.h" 17 18ANDROID_BEGIN_HEADER 19 20/** FILE LOCKS SUPPORT 21 ** 22 ** a FileLock is useful to prevent several emulator instances from using the same 23 ** writable file (e.g. the userdata.img disk images). 24 ** 25 ** create a FileLock object with filelock_create(), the function will return 26 ** NULL only if the corresponding path is already locked by another emulator 27 ** of if the path is read-only. 28 ** 29 ** note that 'path' can designate a non-existing path and that the lock creation 30 ** function can detect stale file locks that can longer when the emulator 31 ** crashes unexpectedly, and will happily clean them for you. 32 ** 33 ** you can call filelock_release() to release a file lock explicitely. otherwise 34 ** all file locks are automatically released when the program exits. 35 **/ 36 37typedef struct FileLock FileLock; 38 39extern FileLock* filelock_create ( const char* path ); 40extern void filelock_release( FileLock* lock ); 41 42ANDROID_END_HEADER 43 44#endif /* _ANDROID_UTILS_FILELOCK_H */ 45