~ubuntu-branches/ubuntu/precise/9base/precise

« back to all changes in this revision

Viewing changes to lib9/dirwstat.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-08-20 17:34:06 UTC
  • mfrom: (6.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090820173406-xpwqa9ruyevvc0ut
Tags: 1:3-3
* Updating maintainer field.
* Updating vcs fields.
* Updating package to standards version 3.8.3.
* Updatin variables writing in rules to consistent style.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#include <libc.h>
4
4
#include <sys/time.h>
5
5
#include <utime.h>
 
6
#include <sys/stat.h>
6
7
 
7
8
int
8
9
dirwstat(char *file, Dir *dir)
9
10
{
 
11
        int ret;
10
12
        struct utimbuf ub;
11
13
 
12
14
        /* BUG handle more */
13
 
        if(~dir->mtime == 0)
14
 
                return 0;
15
 
 
16
 
        ub.actime = dir->mtime;
17
 
        ub.modtime = dir->mtime;
18
 
        return utime(file, &ub);
 
15
        ret = 0;
 
16
        if(~dir->mode != 0){
 
17
                if(chmod(file, dir->mode) < 0)
 
18
                        ret = -1;
 
19
        }
 
20
        if(~dir->mtime != 0){
 
21
                ub.actime = dir->mtime;
 
22
                ub.modtime = dir->mtime;
 
23
                if(utime(file, &ub) < 0)
 
24
                        ret = -1;
 
25
        }
 
26
        if(~dir->length != 0){
 
27
                if(truncate(file, dir->length) < 0)
 
28
                        ret = -1;
 
29
        }
 
30
        return ret;
19
31
}