blob: 1797131246521f44d384085b64d99506ecd01a26 (
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
|
#include <u.h>
#include <libc.h>
#include <thread.h>
#include "dat.h"
#include "fns.h"
int
getdothg(char *dothg, char *path)
{
char buf[MAXPATH], *s;
if(path != nil){
snprint(buf, sizeof(buf), "%s", path);
cleanname(buf);
} else if(getwd(buf, sizeof(buf)) == nil)
return -1;
for(;;){
snprint(dothg, MAXPATH, "%s/.hg", buf);
if(access(dothg, AEXIST) == 0)
return 0;
if(path != nil)
break;
if((s = strrchr(buf, '/')) == nil)
break;
*s = 0;
}
return -1;
}
|