Browse code

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/affxparser@26812 bc3139a8-67e5-0310-9ffc-ced21a209358

Henrik Bengtsson authored on 31/08/2007 22:15:21
Showing 1 changed files

... ...
@@ -126,21 +126,24 @@ findFiles <- function(pattern=NULL, paths=NULL, recursive=FALSE, firstOnly=TRUE,
126 126
       next;
127 127
 
128 128
     # Expand Windows shortcut links?
129
+    files0 <- files;
129 130
     if (hasRutils) {
131
+      # Remember these
130 132
       files <- sapply(files, FUN=filePath, expandLinks="any", USE.NAMES=FALSE);
131 133
     }
132 134
  
133
-    # Keep only existing directories
135
+    # Keep only existing files and directories
134 136
     ok <- sapply(files, FUN=function(file) {
135 137
       (file.exists(path) && !is.na(file.info(file)$isdir));
136
-    }, USE.NAMES=FALSE)
138
+    }, USE.NAMES=FALSE);
137 139
     files <- files[ok];
140
+    files0 <- files0[ok];
138 141
 
139 142
     # Nothing to do?
140 143
     if (length(files) == 0)
141 144
       next;
142 145
 
143
-    # First search the files, then the directories
146
+    # First search the files, then the directories, so...
144 147
     isDir <- sapply(files, FUN=function(file) {
145 148
       file.info(file)$isdir;
146 149
     }, USE.NAMES=FALSE);
... ...
@@ -148,6 +151,7 @@ findFiles <- function(pattern=NULL, paths=NULL, recursive=FALSE, firstOnly=TRUE,
148 151
     # In case some files are non-accessible, exclude them
149 152
     ok <- (!is.na(isDir));
150 153
     files <- files[ok];
154
+    files0 <- files0[ok];
151 155
     isDir <- isDir[ok];
152 156
 
153 157
     # Nothing to do?
... ...
@@ -157,10 +161,12 @@ findFiles <- function(pattern=NULL, paths=NULL, recursive=FALSE, firstOnly=TRUE,
157 161
     # Directories and files in lexicographic order
158 162
     dirs <- files[isDir];
159 163
     files <- files[!isDir];
164
+    files0 <- files0[!isDir];
160 165
 
161 166
     # Keep only files that match the filename pattern
167
+    # of the non-expanded filename.
162 168
     if (!is.null(pattern)) {
163
-      keep <- grep(pattern, basename(files));
169
+      keep <- grep(pattern, basename(files0));
164 170
       files <- files[keep];
165 171
     }
166 172
 
... ...
@@ -196,6 +202,10 @@ findFiles <- function(pattern=NULL, paths=NULL, recursive=FALSE, firstOnly=TRUE,
196 202
 ############################################################################
197 203
 # HISTORY:
198 204
 # 2007-08-30
205
+# o BUG FIX: Pattern matching was done on expanded filenames, whereas they
206
+#   should really be done on the non-expanded ones.  This, only applies to
207
+#   Windows shortcuts, but it is not the destination file that is of 
208
+#   interest, but the name of the shortcut file.
199 209
 # o BUG FIX: The recent update was not grep():ing correctly; forgot to
200 210
 #   extract the basename().
201 211
 # 2007-08-27