windows/SysFileSystem.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 /* REXX Kernel SysFileSystem.hpp */
40 /* */
41 /* System support for FileSystem operations. */
42 /* */
43 /******************************************************************************/
44 
45 #ifndef Included_SysFileSystem
46 #define Included_SysFileSystem
47 
48 #include "windows.h"
49 #include <stdio.h>
50 
51 class RexxString;
52 
53 class SysFileSystem
54 {
55 public:
56  enum
57  {
58  MaximumPathLength = MAX_PATH,
59  MaximumFileNameLength = FILENAME_MAX,
60  MaximumFileNameBuffer = MAX_PATH + FILENAME_MAX
61  };
62 
63  static int stdinHandle;
64  static int stdoutHandle;
65  static int stderrHandle;
66 
67  static const char EOF_Marker;
68  static const char *EOL_Marker; // the end-of-line marker
69  static const char PathDelimiter; // directory path delimiter
70 
71  static const char *getTempFileName();
72  static bool searchFileName(const char * name, char *fullName);
73  static void qualifyStreamName(const char *unqualifiedName, char *qualifiedName, size_t bufferSize);
74  static bool fileExists(const char *name);
75  static bool hasExtension(const char *name);
76  static bool hasDirectory(const char *name);
80  static bool searchName(const char *name, const char *path, const char *extension, char *resolvedName);
81  static bool primitiveSearchName(const char *name, const char *path, const char *extension, char *resolvedName);
82  static bool checkCurrentFile(const char *name, char *resolvedName);
83  static bool searchPath(const char *name, const char *path, const char *extension, char *resolvedName);
84  static void getLongName(char *fullName, size_t size);
85  static bool findFirstFile(const char *name);
86  static bool deleteFile(const char *name);
87  static bool deleteDirectory(const char *name);
88  static bool isDirectory(const char *name);
89  static bool isReadOnly(const char *name);
90  static bool isWriteOnly(const char *name);
91  static bool isFile(const char *name);
92  static bool exists(const char *name);
93  static int64_t getLastModifiedDate(const char *name);
94  static int64_t getFileLength(const char *name);
95  static bool makeDirectory(const char *name);
96  static bool moveFile(const char *oldName, const char *newName);
97  static bool isHidden(const char *name);
98  static bool setLastModifiedDate(const char *name, int64_t time);
99  static bool setFileReadOnly(const char *name);
100  static bool isCaseSensitive();
101  static int getRoots(char *roots);
102  static const char *getSeparator();
103  static const char *getPathSeparator();
104 };
105 
106 class SysFileIterator
107 {
108 public:
109  SysFileIterator(const char *pattern);
111  void close();
112  bool hasNext();
113  void next(char *buffer);
114 protected:
115  bool completed; // the iteration completed flag
116  HANDLE handle; // The handle for the FindFirst operation
117  WIN32_FIND_DATA findFileData;
118 };
119 
120 #endif
121 
WIN32_FIND_DATA findFileData
void next(char *buffer)
SysFileIterator(const char *pattern)
static bool deleteFile(const char *name)
static bool makeDirectory(const char *name)
static const char * getTempFileName()
static bool isHidden(const char *name)
static void getLongName(char *fullName, size_t size)
static bool fileExists(const char *name)
static bool deleteDirectory(const char *name)
static RexxString * extractFile(RexxString *file)
static const char * getPathSeparator()
static bool isDirectory(const char *name)
static bool primitiveSearchName(const char *name, const char *path, const char *extension, char *resolvedName)
static bool checkCurrentFile(const char *name, char *resolvedName)
static void qualifyStreamName(const char *unqualifiedName, char *qualifiedName, size_t bufferSize)
static bool isCaseSensitive()
static int64_t getFileLength(const char *name)
static const char * EOL_Marker
static RexxString * extractExtension(RexxString *file)
static bool isFile(const char *name)
static bool setFileReadOnly(const char *name)
static bool searchFileName(const char *name, char *fullName)
static bool isReadOnly(const char *name)
static bool isWriteOnly(const char *name)
static bool setLastModifiedDate(const char *name, int64_t time)
static int getRoots(char *roots)
static bool moveFile(const char *oldName, const char *newName)
static int64_t getLastModifiedDate(const char *name)
static bool hasDirectory(const char *name)
static const char PathDelimiter
static const char * getSeparator()
static RexxString * extractDirectory(RexxString *file)
static bool hasExtension(const char *name)
static bool searchPath(const char *name, const char *path, char *resolvedName)
static bool searchName(const char *name, const char *path, const char *extension, char *resolvedName)
static const char EOF_Marker
static bool exists(const char *name)
static bool findFirstFile(const char *name)
signed __int64 int64_t