WinNTFileSystem_md.c revision 357
0N/A * Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A/* Access APIs for Win2K and above */ 0N/A/* -- Path operations -- */ 0N/A /*we estimate the max length of memory needed as 0N/A "currentDir. length + pathname.length" 0N/A/* -- Attribute accessors -- */ 0N/A/* Check whether or not the file name in "path" is a Windows reserved 0N/A device name (CON, PRN, AUX, NUL, COM[1-9], LPT[1-9]) based on the 0N/A returned result from GetFullPathName, which should be in thr form of 0N/A "\\.\[ReservedDeviceName]" if the path represents a reserved device 0N/A Note1: GetFullPathName doesn't think "CLOCK$" (which is no longer 0N/A important anyway) is a device name, so we don't check it here. 0N/A GetFileAttributesEx will catch it later by returning 0 on NT/XP/ 0N/A Note2: Theoretically the implementation could just lookup the table 0N/A below linearly if the first 4 characters of the fullpath returned 0N/A from GetFullPathName are "\\.\". The current implementation should 0N/A achieve the same result. If Microsoft add more names into their 0N/A reserved device name repository in the future, which probably will 0N/A never happen, we will need to revisit the lookup implementation. 0N/Astatic WCHAR* ReservedDEviceNames[] = { 0N/A L"CON", L"PRN", L"AUX", L"NUL", 0N/A L"COM1", L"COM2", L"COM3", L"COM4", L"COM5", L"COM6", L"COM7", L"COM8", L"COM9", 0N/A L"LPT1", L"LPT2", L"LPT3", L"LPT4", L"LPT5", L"LPT6", L"LPT7", L"LPT8", L"LPT9", 357N/A /* Read-only attribute ignored on directories */ 0N/A /* Device query access */ 0N/A /* No security attributes */ 0N/A /* Open existing or fail */ 0N/A /* Backup semantics for directories */ 0N/A /* No template file */ 0N/A /* The error is "share violation", which means the file/dir 0N/A must exists. Try _wstati64, we know this at least works 0N/A/* -- File operations -- */ 0N/A // If a directory by the named path already exists, 0N/A // return false (behavior of solaris and linux) instead of 0N/A // throwing an exception 0N/A /* Returns 0 on success */ 0N/A /* Remove trailing space chars from directory name */ 0N/A /* Append "*", or possibly "\\*", to path */ 0N/A /* No '\\' needed for cases like "\" or "Z:" or "Z:\" */ 0N/A /* Open handle to the first file */ 0N/A // No files found - return an empty array 0N/A /* Allocate an initial String array */ 0N/A if (
rv ==
NULL)
// Couldn't allocate an array 0N/A /* Scan the directory */ 0N/A /* Copy the final results into an appropriately-sized array */ 0N/A /* Exception is pending */ 0N/A/* -- Filesystem interface -- */