aboutsummaryrefslogtreecommitdiffstats
path: root/homedir.c
blob: 89766d6078dcdfac3671effe6a273b6b24edf1f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "grv.h"

#ifdef __unix__
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#endif

void goto_grv_dir(void)
{
  /* On Unix, save stuff in a ~/.grv directory */
#ifdef __unix__
  {
    char *home = getenv("HOME");
    char *grvd = getenv("GRV_DIR");

    if ( !grvd ) {
      grvd = alloca(strlen(home)+6);
      if ( grvd ) {
	sprintf(grvd, "%s/.grv", home);
	mkdir(grvd, 0777);	/* Make .grv directory if missing */
      }
    }

    if ( grvd )
      chdir(grvd);		/* Change to .grv directory */
  }
#endif
}