Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d5f14fb0b2a286f218d9814cff231f1a34f6adfb
Ticket: 230474ffffffffffffffffffffffffffffffffff
glob returns hidden files on win/macos
User & Date: vincentdarley on 2001-01-30 17:14:11
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    On Unix, 'glob' only returns the hidden/invisible files (matching .*) if the pattern starts with '.' -- i.e. if the user specifically requested them.  On MacOS and Windows, in which invisibility is specified differently, hidden files are returned by default, even though the '-types hidden' option provides a mechanism to return them if they are desired.
    
    For consistency the MacOS and Windows versions of glob should be updated to follow the Unix example.  Here's a patch for MacOS (tclMacFile.c should read):
    
    int typeOk = 1;
    if (types == NULL) {
        /* If invisible, don't return the file */
        if (pb.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible) {
    typeOk = 0;
        }
    } else {
        if (pb.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible) {
    /* If invisible */
    if ((types->perm == 0) || 
      !(types->perm & TCL_GLOB_PERM_HIDDEN)) {
        typeOk = 0;
    }
        } else {
    /* Visible */
    if ((types->perm == 0) || 
      (types->perm & TCL_GLOB_PERM_HIDDEN)) {
        typeOk = 0;
    }
        }
        if (typeOk == 1 && types->perm != 0) {
    if (
        ((types->perm & TCL_GLOB_PERM_RONLY) &&
        !(pb.hFileInfo.ioFlAttrib & 1)) ||
        ((types->perm & TCL_GLOB_PERM_R) &&
        (TclpAccess(fname, R_OK) != 0)) ||
        ((types->perm & TCL_GLOB_PERM_W) &&
        (TclpAccess(fname, W_OK) != 0)) ||
        ((types->perm & TCL_GLOB_PERM_X) &&
        (TclpAccess(fname, X_OK) != 0))
        ) {
        typeOk = 0;
    }
        }
    
    and for Windows (tclWinFile.c):
    
    int typeOk = 1;
    attr = (*tclWinProcs->getFileAttributesProc)(nativeName);
    if (types == NULL) {
        /* If invisible, don't return the file */
        if (attr & FILE_ATTRIBUTE_HIDDEN) {
    typeOk = 0;
        }
    } else {
        if (attr & FILE_ATTRIBUTE_HIDDEN) {
    /* If invisible */
    if ((types->perm == 0) || 
      !(types->perm & TCL_GLOB_PERM_HIDDEN)) {
        typeOk = 0;
    }
        } else {
    /* Visible */
    if ((types->perm == 0) || 
      (types->perm & TCL_GLOB_PERM_HIDDEN)) {
        typeOk = 0;
    }
        }
        if (typeOk == 1 && types->perm != 0) {
    if (
        ((types->perm & TCL_GLOB_PERM_RONLY) &&
        !(attr & FILE_ATTRIBUTE_READONLY)) ||
        ((types->perm & TCL_GLOB_PERM_R) &&
        (TclpAccess(fname, R_OK) != 0)) ||
        ((types->perm & TCL_GLOB_PERM_W) &&
        (TclpAccess(fname, W_OK) != 0)) ||
        ((types->perm & TCL_GLOB_PERM_X) &&
        (TclpAccess(fname, X_OK) != 0))
        ) {
        typeOk = 0;
    }
        }
    
    
  4. foundin changed to: "obsolete: 8.4a2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "vincentdarley"
  9. subsystem changed to: "37. File System"
  10. title changed to: "glob returns hidden files on win/macos"
  11. type changed to: "Bug"