• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /** FILE LOCKS SUPPORT
17  **
18  ** a FileLock is useful to prevent several emulator instances from using the same
19  ** writable file (e.g. the userdata.img disk images).
20  **
21  ** create a FileLock object with filelock_create(), the function will return
22  ** NULL only if the corresponding path is already locked by another emulator
23  ** of if the path is read-only.
24  **
25  ** note that 'path' can designate a non-existing path and that the lock creation
26  ** function can detect stale file locks that can longer when the emulator
27  ** crashes unexpectedly, and will happily clean them for you.
28  **
29  ** you can call filelock_release() to release a file lock explicitely. otherwise
30  ** all file locks are automatically released when the program exits.
31  **/
32 
33 typedef struct FileLock  FileLock;
34 
35 extern FileLock*  filelock_create ( const char*  path );
36 extern void       filelock_release( FileLock*  lock );
37 
38 #endif /* _ANDROID_UTILS_FILELOCK_H */
39