mirror of git://git.suckless.org/sbase
buf -> cwd
This commit is contained in:
parent
8be2afd2c3
commit
217e9bce9c
10
ls.c
10
ls.c
|
@ -89,13 +89,13 @@ ls(char *path)
|
||||||
void
|
void
|
||||||
lsdir(const char *path)
|
lsdir(const char *path)
|
||||||
{
|
{
|
||||||
char *buf, *p;
|
char *cwd, *p;
|
||||||
long i, n = 0;
|
long i, n = 0;
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
Entry *ents = NULL;
|
Entry *ents = NULL;
|
||||||
|
|
||||||
buf = agetcwd();
|
cwd = agetcwd();
|
||||||
if(!(dp = opendir(path)))
|
if(!(dp = opendir(path)))
|
||||||
eprintf("opendir %s:", path);
|
eprintf("opendir %s:", path);
|
||||||
if(chdir(path) != 0)
|
if(chdir(path) != 0)
|
||||||
|
@ -119,10 +119,10 @@ lsdir(const char *path)
|
||||||
output(&ents[i]);
|
output(&ents[i]);
|
||||||
free(ents[i].name);
|
free(ents[i].name);
|
||||||
}
|
}
|
||||||
if(chdir(buf) != 0)
|
if(chdir(cwd) != 0)
|
||||||
eprintf("chdir %s:", buf);
|
eprintf("chdir %s:", cwd);
|
||||||
free(ents);
|
free(ents);
|
||||||
free(buf);
|
free(cwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
void
|
void
|
||||||
recurse(const char *path, void (*fn)(const char *))
|
recurse(const char *path, void (*fn)(const char *))
|
||||||
{
|
{
|
||||||
char *buf;
|
char *cwd;
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ recurse(const char *path, void (*fn)(const char *))
|
||||||
else
|
else
|
||||||
eprintf("opendir %s:", path);
|
eprintf("opendir %s:", path);
|
||||||
}
|
}
|
||||||
buf = agetcwd();
|
cwd = agetcwd();
|
||||||
if(chdir(path) != 0)
|
if(chdir(path) != 0)
|
||||||
eprintf("chdir %s:", path);
|
eprintf("chdir %s:", path);
|
||||||
while((d = readdir(dp)))
|
while((d = readdir(dp)))
|
||||||
|
@ -28,7 +28,7 @@ recurse(const char *path, void (*fn)(const char *))
|
||||||
fn(d->d_name);
|
fn(d->d_name);
|
||||||
|
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
if(chdir(buf) != 0)
|
if(chdir(cwd) != 0)
|
||||||
eprintf("chdir %s:", buf);
|
eprintf("chdir %s:", cwd);
|
||||||
free(buf);
|
free(cwd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue