vpl.cxx
Go to the documentation of this file.
1 // This is core/vpl/os_win32/vpl.cxx
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <direct.h>
5 #include <io.h>
6 #include <process.h>
7 #include <windows.h>
8 
9 char *
10 vpl_getcwd( char *buf, std::size_t buf_size )
11 {
12  return _getcwd( buf, (int)buf_size );
13 }
14 
15 int
16 vpl_mkdir( const char *dir, unsigned short /*mode*/ )
17 {
18  _mkdir( dir );
19  return 0;
20 }
21 
22 int
23 vpl_rmdir( const char *dir )
24 {
25  return _rmdir( dir );
26 }
27 
28 int
29 vpl_chdir( const char *dir )
30 {
31  return _chdir( dir );
32 }
33 
34 int
35 vpl_unlink( const char *file )
36 {
37  return _unlink( file );
38 }
39 
40 unsigned int
41 vpl_sleep( unsigned int t )
42 {
43  Sleep( long(t) * 1000 );
44  return 0;
45 }
46 
47 int
48 vpl_usleep( unsigned int t )
49 {
50  Sleep( t / 1000 );
51  return 0;
52 }
53 
54 unsigned
56 {
57  return _getpid();
58 }
59 
60 int vpl_putenv ( const char * envvar )
61 {
62  return _putenv(envvar);
63 }
64 
65 
66 int vpl_gethostname(char *name, std::size_t len)
67 {
68 #if defined(_MSC_VER)
69  static bool wsa_initialised = false;
70 
71  if (!wsa_initialised)
72  {
73  WSADATA wsaData;
74  WSAStartup(MAKEWORD(2,2), &wsaData);
75  }
76 #endif
77  return gethostname(name, len);
78 }
unsigned int vpl_sleep(unsigned int t)
Sleep for t seconds.
Definition: vpl.cxx:47
int vpl_usleep(unsigned int t)
Sleep for t microseconds.
Definition: vpl.cxx:53
char * vpl_getcwd(char *buf, std::size_t buf_size)
Get the pathname of the current working directory.
Definition: vpl.cxx:17
unsigned vpl_getpid()
Get the process identifier.
Definition: vpl.cxx:69
int vpl_putenv(const char *envvar)
Set environment variable.
Definition: vpl.cxx:79
int vpl_rmdir(const char *dir)
Remove the directory dir.
Definition: vpl.cxx:29
int vpl_mkdir(const char *dir, unsigned short mode)
Create a new directory dir with permissions mode.
Definition: vpl.cxx:23
int vpl_chdir(const char *dir)
Change the working directory to dir.
Definition: vpl.cxx:35
int vpl_gethostname(char *name, size_t len)
Definition: vpl.cxx:92
int vpl_unlink(const char *file)
Remove the file file.
Definition: vpl.cxx:41