(file) Return to dir.h CVS log (file) (dir) Up to [OMI] / omi / base

  1 mike  1.1 /*
  2           **==============================================================================
  3           **
  4           ** Open Management Infrastructure (OMI)
  5           **
  6           ** Copyright (c) Microsoft Corporation
  7           ** 
  8           ** Licensed under the Apache License, Version 2.0 (the "License"); you may not 
  9           ** use this file except in compliance with the License. You may obtain a copy 
 10           ** of the License at 
 11           **
 12           **     http://www.apache.org/licenses/LICENSE-2.0 
 13           **
 14           ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15           ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
 16           ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
 17           ** MERCHANTABLITY OR NON-INFRINGEMENT. 
 18           **
 19           ** See the Apache 2 License for the specific language governing permissions 
 20           ** and limitations under the License.
 21           **
 22 mike  1.1 **==============================================================================
 23           */
 24           
 25           #ifndef _base_dir_h
 26           #define _base_dir_h
 27           
 28           #include <common.h>
 29           #include <base/strings.h>
 30           
 31           #if defined(_MSC_VER)
 32           # include <io.h>
 33           # include <direct.h>
 34           #else
 35           # include <sys/types.h>
 36           # include <sys/stat.h>
 37           # include <unistd.h>
 38           #endif
 39           
 40           BEGIN_EXTERNC
 41           
 42           MI_INLINE int Mkdir(const char* path, int mode)
 43 mike  1.1 {
 44           #if defined(_MSC_VER)
 45               MI_UNUSED(mode);
 46               return _mkdir(path);
 47           #else
 48               return mkdir(path, mode);
 49           #endif
 50           }
 51           
 52           /* Create the given directory and any directories along the path */
 53           int Mkdirhier(const char* path, int mode);
 54           
 55           MI_INLINE int Chdir(const char* path)
 56           {
 57           #if defined(_MSC_VER)
 58               return _chdir(path);
 59           #else
 60               return chdir(path);
 61           #endif
 62           }
 63           
 64 mike  1.1 MI_INLINE int Rmdir(const char* path)
 65           {
 66           #if defined(_MSC_VER)
 67               return _rmdir(path);
 68           #else
 69               return rmdir(path);
 70           #endif
 71           }
 72           
 73           MI_Boolean Isdir(const char* path);
 74           
 75           typedef struct _DirEnt 
 76           {
 77               char name[MAX_PATH_SIZE];
 78               int type;
 79           }
 80           DirEnt;
 81           
 82           typedef struct _Dir Dir;
 83           
 84           Dir* Dir_Open(const char* path);
 85 mike  1.1 
 86           DirEnt* Dir_Read(Dir* dir);
 87           
 88           int Dir_Close(Dir* dir);
 89           
 90           char** Listdir(const char* path);
 91           
 92           /* Format TMPDIR/file (leave result in 'path' and return path) */
 93           char* TempPath(char path[MAX_PATH_SIZE], const char* file);
 94           
 95           /* Find the 'basename' of a path (final component without leading directory) */
 96           const char* Basename(const char* path);
 97           
 98           MI_Char* ZSTempPath(MI_Char path[MAX_PATH_SIZE], const char* file);
 99           
100           END_EXTERNC
101           
102           #endif /* _base_dir_h */

ViewCVS 0.9.2