Cross-platform utility functions

BOINC supplies various functions that may be useful in applications, such as cross-platform interfaces to operating system features.


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 number of seconds
double drand(), rand_normal()
uniform and normal random numbers
read_file_string(const char* path, string&)
read file into string

File system

File system 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);
  extern int boinc_chown(const char*, gid_t);
  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

XML parsing

See lib/parse.cpp,h

String functions

See lib/str_util.h

Cross-platform support for strlcpy(), strlcat(), strcasestr() and strcasecmp() is in lib/str_replace.cpp,h

RSA cryptography

See lib/crypt.cpp,h

MD5 hash

See lib/md5.cpp,h


See lib/synch.cpp,h

Shared memory

See lib/shmem.cpp,h

Network communication

See lib/network.cpp,h

Process control

See lib/proc_control.cpp,h

Last modified 2 years ago Last modified on 01/26/15 11:55:55