Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | When removing a directory on Windows, make sure it is a real directory (i.e. not a junction, symbolic link, etc). |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
9bb25a28627be067847de63528aa2398 |
| User & Date: | mistachkin 2019-07-14 04:46:09.191 |
Context
|
2019-07-14
| ||
| 20:32 | Try to omit unnecessary indentation on the hierarchical forum display. Include an "in reply to" mark on the hierarchical display. check-in: 97697b7956 user: drh tags: trunk | |
| 04:46 | When removing a directory on Windows, make sure it is a real directory (i.e. not a junction, symbolic link, etc). check-in: 9bb25a2862 user: mistachkin tags: trunk | |
|
2019-07-13
| ||
| 19:31 | Eliminate all usage of Tcl_GetStringResult(), since that causes loss of Tcl_Obj representation in Tcl 8.x (this is solved in Tcl 9.0) check-in: 743e166cf9 user: jan.nijtmans tags: trunk | |
Changes
Changes to src/file.c.
| ︙ | ︙ | |||
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
}
}
}
free(zName);
return rc;
}
/*
** Removes the directory named in the argument, if it exists. The directory
** must be empty and cannot be the current directory or the root directory.
**
** Returns zero upon success.
*/
int file_rmdir(const char *zName){
int rc = file_isdir(zName, RepoFILE);
if( rc==2 ) return 1; /* cannot remove normal file */
if( rc==1 ){
#if defined(_WIN32)
wchar_t *zMbcs = fossil_utf8_to_path(zName, 1);
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > | 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 |
}
}
}
free(zName);
return rc;
}
#if defined(_WIN32)
/*
** Returns non-zero if the specified name represents a real directory, i.e.
** not a junction or symbolic link. This is important for some operations,
** e.g. removing directories via _wrmdir(), because its detection of empty
** directories will (apparently) not work right for junctions and symbolic
** links, etc.
*/
int file_is_normal_dir(wchar_t *zName){
/*
** Mask off attributes, applicable to directories, that are harmless for
** our purposes. This may need to be updated if other attributes should
** be ignored by this function.
*/
DWORD dwAttributes = GetFileAttributesW(zName);
if( dwAttributes==INVALID_FILE_ATTRIBUTES ) return 0;
dwAttributes &= ~(
FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_COMPRESSED |
FILE_ATTRIBUTE_ENCRYPTED | FILE_ATTRIBUTE_NORMAL |
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
);
return dwAttributes==FILE_ATTRIBUTE_DIRECTORY;
}
/*
** COMMAND: test-is-normal-dir
**
** Usage: %fossil test-is-normal-dir NAME...
**
** Returns non-zero if the specified names represent real directories, i.e.
** not junctions, symbolic links, etc.
*/
void test_is_normal_dir(void){
int i;
for(i=2; i<g.argc; i++){
wchar_t *zMbcs = fossil_utf8_to_path(g.argv[i], 1);
fossil_print("ATTRS \"%s\" -> %lx\n", g.argv[i], GetFileAttributesW(zMbcs));
fossil_print("ISDIR \"%s\" -> %d\n", g.argv[i], file_is_normal_dir(zMbcs));
fossil_path_free(zMbcs);
}
}
#endif
/*
** Removes the directory named in the argument, if it exists. The directory
** must be empty and cannot be the current directory or the root directory.
**
** Returns zero upon success.
*/
int file_rmdir(const char *zName){
int rc = file_isdir(zName, RepoFILE);
if( rc==2 ) return 1; /* cannot remove normal file */
if( rc==1 ){
#if defined(_WIN32)
wchar_t *zMbcs = fossil_utf8_to_path(zName, 1);
if( file_is_normal_dir(zMbcs) ){
rc = _wrmdir(zMbcs);
}else{
rc = ENOTDIR; /* junction, symbolic link, etc. */
}
#else
char *zMbcs = fossil_utf8_to_path(zName, 1);
rc = rmdir(zName);
#endif
fossil_path_free(zMbcs);
return rc;
}
|
| ︙ | ︙ |