~ubuntu-branches/debian/sid/boinc/sid

« back to all changes in this revision

Viewing changes to lib/filesys.cpp

  • Committer: Package Import Robot
  • Author(s): Steffen Moeller
  • Date: 2011-08-08 01:36:51 UTC
  • mfrom: (6.1.11 experimental)
  • Revision ID: package-import@ubuntu.com-20110808013651-m1hs3cltiveuteyn
Tags: 6.13.1+dfsg-2
* Bringing notify patch to unstable.
* Adjusted build dependency to libjpeg-dev (Closes: #641093)
* Further improvements on stripchart.

Show diffs side-by-side

added added

removed removed

Lines of Context:
403
403
    } while (FindNextFileA(hFind, &findData));
404
404
        ::FindClose(hFind);
405
405
#else
406
 
    char filename[256], subdir[256];
 
406
    char filename[1024], subdir[1024];
407
407
    int retval=0;
408
408
    DIRREF dirp;
409
409
    double x;
422
422
                if (retval) continue;
423
423
                size += x;
424
424
            }
425
 
        } else {
 
425
        } else if (is_file(subdir)) {
426
426
            retval = file_size(subdir, x);
427
427
            if (retval) continue;
428
428
            size += x;
434
434
}
435
435
 
436
436
FILE* boinc_fopen(const char* path, const char* mode) {
437
 
 
438
437
    // if opening for read, and file isn't there,
439
438
    // leave now (avoid 5-second delay!!)
440
439
    //
486
485
 
487
486
 
488
487
int boinc_file_exists(const char* path) {
489
 
   struct stat buf;
490
 
   if (stat(path, &buf)) {
491
 
       return false;     // stat() returns zero on success
492
 
   }
493
 
   return true;
 
488
    struct stat buf;
 
489
    if (stat(path, &buf)) {
 
490
        return false;     // stat() returns zero on success
 
491
    }
 
492
    return true;
494
493
}
495
494
 
496
495
// same, but doesn't traverse symlinks
497
496
//
498
497
int boinc_file_or_symlink_exists(const char* path) {
499
 
   struct stat buf;
 
498
    struct stat buf;
500
499
#ifdef _WIN32
501
 
   if (stat(path, &buf)) {
 
500
    if (stat(path, &buf)) {
502
501
#else
503
 
   if (lstat(path, &buf)) {
 
502
    if (lstat(path, &buf)) {
504
503
#endif
505
 
       return false;     // stat() returns zero on success
506
 
   }
507
 
   return true;
 
504
        return false;     // stat() returns zero on success
 
505
    }
 
506
    return true;
508
507
}
509
508
 
510
509
// returns zero on success, nonzero if didn't touch file
755
754
    if (pGetDiskFreeSpaceEx) {
756
755
        ULARGE_INTEGER TotalNumberOfFreeBytes;
757
756
        ULARGE_INTEGER TotalNumberOfBytes;
758
 
        ULARGE_INTEGER TotalNumberOfBytesFreeToCaller;
 
757
        ULARGE_INTEGER FreeBytesAvailable;
759
758
        pGetDiskFreeSpaceEx(
760
 
            buf, &TotalNumberOfBytesFreeToCaller, &TotalNumberOfBytes,
 
759
            buf, &FreeBytesAvailable, &TotalNumberOfBytes,
761
760
            &TotalNumberOfFreeBytes
762
761
        );
763
762
        signed __int64 uMB;
764
 
        uMB = TotalNumberOfFreeBytes.QuadPart / (1024 * 1024);
 
763
        uMB = FreeBytesAvailable.QuadPart / (1024 * 1024);
765
764
        free_space = uMB * 1024.0 * 1024.0;
766
765
        uMB = TotalNumberOfBytes.QuadPart / (1024 * 1024);
767
766
        total_space = uMB * 1024.0 * 1024.0;