Fossil

Check-in [3714782631]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use SetCurrentDirectoryW/GetFileAttributesExW in stead of _wchdir/_wstati64 (which cannot handle long pathnames)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3714782631607e930dff33f7c544c857ec606e3a
User & Date: jan.nijtmans 2013-12-13 09:40:58.983
Context
2013-12-13
12:26
If the "Branching" checkbox is unchecked, the "Branch Closure" label should return to its original branchname. Add a javascript handler doing exactly that. check-in: 2cb54f3981 user: jan.nijtmans tags: trunk
11:31
Merge trunk. Fix uninitialized variable. Less copying of complete structure content. check-in: 85528ef507 user: jan.nijtmans tags: tkt-change-hook
09:40
Use SetCurrentDirectoryW/GetFileAttributesExW in stead of _wchdir/_wstati64 (which cannot handle long pathnames) check-in: 3714782631 user: jan.nijtmans tags: trunk
08:40
When branchname in ci_edit page changes, adapt remaining form to the name-change using some javascript. Thanks to Andy Bradford for the idea (adapted/simplified from the "hidden-tag" branch)! check-in: cf9293ad53 user: jan.nijtmans tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/file.c.
45
46
47
48
49
50
51
52





53
54
55
56
57
58
59
** The file status information from the most recent stat() call.
**
** Use _stati64 rather than stat on windows, in order to handle files
** larger than 2GB.
*/
#if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER))
# undef stat
# define stat _stati64





#endif
/*
** On Windows S_ISLNK always returns FALSE.
*/
#if !defined(S_ISLNK)
# define S_ISLNK(x) (0)
#endif







|
>
>
>
>
>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
** The file status information from the most recent stat() call.
**
** Use _stati64 rather than stat on windows, in order to handle files
** larger than 2GB.
*/
#if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER))
# undef stat
# define stat _fossil_stati64
struct stat {
    i64 st_size;
    i64 st_mtime;
    int st_mode;
};
#endif
/*
** On Windows S_ISLNK always returns FALSE.
*/
#if !defined(S_ISLNK)
# define S_ISLNK(x) (0)
#endif
71
72
73
74
75
76
77

78
79









80
81
82
83
84
85
86
  char *zMbcs = fossil_utf8_to_filename(zFilename);
  if( isWd && g.allowSymlinks ){
    rc = lstat(zMbcs, buf);
  }else{
    rc = stat(zMbcs, buf);
  }
#else

  wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
  rc = _wstati64(zMbcs, buf);









#endif
  fossil_filename_free(zMbcs);
  return rc;
}

/*
** Fill in the fileStat variable for the file named zFilename.







>

|
>
>
>
>
>
>
>
>
>







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  char *zMbcs = fossil_utf8_to_filename(zFilename);
  if( isWd && g.allowSymlinks ){
    rc = lstat(zMbcs, buf);
  }else{
    rc = stat(zMbcs, buf);
  }
#else
  WIN32_FILE_ATTRIBUTE_DATA attr;
  wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
  rc = !GetFileAttributesExW(zMbcs, GetFileExInfoStandard, &attr);
  if( !rc ){
    ULARGE_INTEGER ull;
    ull.LowPart = attr.ftLastWriteTime.dwLowDateTime;
    ull.HighPart = attr.ftLastWriteTime.dwHighDateTime;
    buf->st_mode = (attr.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)?
                    S_IFDIR:S_IFREG;
    buf->st_size = (((i64)attr.nFileSizeHigh)<<32) | attr.nFileSizeLow;
    buf->st_mtime = ull.QuadPart / 10000000ULL - 11644473600ULL;
  }
#endif
  fossil_filename_free(zMbcs);
  return rc;
}

/*
** Fill in the fileStat variable for the file named zFilename.
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
** Wrapper around the chdir() system call.
** If bChroot=1, do a chroot to this dir as well
** (UNIX only)
*/
int file_chdir(const char *zChDir, int bChroot){
#ifdef _WIN32
  wchar_t *zPath = fossil_utf8_to_filename(zChDir);
  int rc = _wchdir(zPath);
#else
  char *zPath = fossil_utf8_to_filename(zChDir);
  int rc = chdir(zPath);
  if( !rc && bChroot ){
    rc = chroot(zPath);
    if( !rc ) rc = chdir("/");
  }







|







334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
** Wrapper around the chdir() system call.
** If bChroot=1, do a chroot to this dir as well
** (UNIX only)
*/
int file_chdir(const char *zChDir, int bChroot){
#ifdef _WIN32
  wchar_t *zPath = fossil_utf8_to_filename(zChDir);
  int rc = SetCurrentDirectoryW(zPath)==0;
#else
  char *zPath = fossil_utf8_to_filename(zChDir);
  int rc = chdir(zPath);
  if( !rc && bChroot ){
    rc = chroot(zPath);
    if( !rc ) rc = chdir("/");
  }