File: wrap_chdir.c

package info (click to toggle)
bglibs 2.04%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,368 kB
  • sloc: ansic: 15,820; perl: 674; sh: 64; makefile: 26
file content (24 lines) | stat: -rw-r--r-- 458 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <unistd.h>

#include "msg.h"
#include "wrap.h"

void wrap_chdir(const char* dir)
{
  if (chdir(dir) != 0)
    die3sys(wrap_exit, "Could not chdir to '", dir, "'");
}

#ifdef SELFTEST_MAIN
MAIN
{
  wrap_exit = 0;
  wrap_chdir(".");
  obuf_putsflush(&outbuf, "worked\n");
  wrap_chdir("/this/dir/should/not/exist");
}
#endif
#ifdef SELFTEST_EXP
worked
selftest: Fatal: Could not chdir to '/this/dir/should/not/exist': No such file or directory
#endif