Version 10 (modified by 10 years ago) (diff) | ,
---|
Cross-platform functions
If you're porting an existing Unix app to Windows, you'll find that while most POSIX calls are supported on Windows, some are not.
BOINC supplies some generic functions with implementations for all platforms. Similar code may be available from other open-source projects
General functions (in lib/util.cpp/h):
- double dtime()
- return Unix time with fractional seconds
- double dday()
- return Unix time at start of this day
- void boinc_sleep(double)
- sleep for given period
- double drand(), rand_normal()
- uniform and normal random numbers read_file_string(const char* path, std::string&):: read file into string
Filesystem functions (in lib/filesys.cpp/h):
extern int boinc_delete_file(const char*); extern int boinc_touch_file(const char *path); extern FILE* boinc_fopen(const char* path, const char* mode); extern int boinc_copy(const char* orig, const char* newf); extern int boinc_rename(const char* old, const char* newf); extern int boinc_mkdir(const char*); #ifdef _WIN32 extern int boinc_allocate_file(const char*, double size); #else extern int boinc_chown(const char*, gid_t); #endif extern int boinc_rmdir(const char*); extern void boinc_getcwd(char*); extern void relative_to_absolute(const char* relname, char* path); extern int is_file(const char* path); extern int is_dir(const char* path); extern int is_file_follow_symlinks(const char* path); extern int is_dir_follow_symlinks(const char* path); extern int is_symlink(const char* path); extern bool is_dir_empty(const char*); extern int boinc_truncate(const char*, double); extern int boinc_file_exists(const char* path); extern int boinc_file_or_symlink_exists(const char* path); extern int file_size(const char*, double&); extern int clean_out_dir(const char*); extern int dir_size(const char* dirpath, double&, bool recurse=true); class DirScanner; // for scanning directories struct FILE_LOCK; // for locking a file
Various RSA cryptographic functions: lib/crypt.cpp,h
Various MD5 hash functions: lib/md5.cpp,h
Semaphores: lib/synch.cpp,h
Shared memory: lib/shmem.cpp,h
Network communication: lib/network.cpp,h