source:
orxonox.OLD/branches/qt_gui/src/lib/util/file.cc
@
7615
| Last change on this file since 7615 was 7615, checked in by bensch, 19 years ago | |
|---|---|
| File size: 2.4 KB | |
| Rev | Line | |
|---|---|---|
| [7609] | 1 | /* |
| 2 | orxonox - the future of 3D-vertical-scrollers | |
| 3 | ||
| 4 | Copyright (C) 2004 orx | |
| 5 | ||
| 6 | This program is free software; you can redistribute it and/or modify | |
| 7 | it under the terms of the GNU General Public License as published by | |
| 8 | the Free Software Foundation; either version 2, or (at your option) | |
| 9 | any later version. | |
| 10 | ||
| 11 | ### File Specific: | |
| 12 | main-programmer: Benjamin Grauer | |
| 13 | co-programmer: ... | |
| 14 | */ | |
| 15 | ||
| [7611] | 16 | #include "file.h" |
| [7609] | 17 | |
| [7615] | 18 | #include <sys/types.h> |
| 19 | #include <sys/stat.h> | |
| 20 | ||
| [7611] | 21 | #ifdef __unix__ |
| 22 | #include <unistd.h> | |
| 23 | #elif __WIN32__ || _MS_DOS_ | |
| 24 | #include <dir.h> | |
| 25 | #else | |
| 26 | #include <direct.h> | |
| 27 | #endif | |
| 28 | ||
| 29 | ||
| 30 | ||
| 31 | File::File() | |
| 32 | { | |
| 33 | #warning implement | |
| 34 | } | |
| 35 | ||
| 36 | File::File(const std::string& fileName) | |
| 37 | { | |
| 38 | #warning implement | |
| 39 | } | |
| 40 | ||
| 41 | File::File(const File& file) | |
| 42 | { | |
| 43 | #warning implement | |
| 44 | } | |
| 45 | ||
| 46 | File::~File() | |
| 47 | { | |
| 48 | #warning implement | |
| 49 | } | |
| 50 | ||
| 51 | bool File::open(OpenMode mode) | |
| 52 | { | |
| 53 | #warning implement | |
| 54 | } | |
| [7615] | 55 | |
| [7611] | 56 | bool File::close() |
| 57 | { | |
| 58 | #warning implement | |
| 59 | } | |
| [7615] | 60 | |
| [7611] | 61 | int File::handle() |
| 62 | { | |
| 63 | #warning implement | |
| 64 | } | |
| 65 | ||
| 66 | bool File::exists() | |
| 67 | { | |
| 68 | #warning implement | |
| 69 | } | |
| [7615] | 70 | |
| [7611] | 71 | bool File::isLink() |
| 72 | { | |
| 73 | #warning implement | |
| [7615] | 74 | } |
| 75 | // only on UNIX | |
| [7611] | 76 | bool File::isFile() |
| 77 | { | |
| 78 | #warning implement | |
| 79 | } | |
| [7615] | 80 | |
| [7611] | 81 | bool File::isDirectory() |
| 82 | { | |
| [7612] | 83 | std::string tmpDirName = this->_name; |
| 84 | struct stat status; | |
| 85 | ||
| 86 | // checking for the termination of the string given. If there is a "/" at the end cut it away | |
| [7615] | 87 | if (this->_name[this->_name.size()-1] == '/' || |
| 88 | this->_name[this->_name.size()-1] == '\\') | |
| [7612] | 89 | { |
| 90 | tmpDirName.erase(tmpDirName.size()-1); | |
| 91 | } | |
| 92 | ||
| 93 | if(!stat(tmpDirName.c_str(), &status)) | |
| 94 | { | |
| 95 | if (status.st_mode & (S_IFDIR | |
| 96 | #ifndef __WIN32__ | |
| 97 | | S_IFLNK | |
| 98 | #endif | |
| 99 | )) | |
| 100 | { | |
| 101 | return true; | |
| 102 | } | |
| 103 | else | |
| 104 | return false; | |
| 105 | } | |
| 106 | else | |
| 107 | return false; | |
| [7611] | 108 | } |
| [7612] | 109 | |
| [7611] | 110 | bool File::isReadeable() |
| 111 | { | |
| [7612] | 112 | |
| [7611] | 113 | #warning implement |
| 114 | } | |
| [7612] | 115 | |
| [7611] | 116 | bool File::isWriteable() |
| 117 | { | |
| 118 | #warning implement | |
| 119 | } | |
| 120 | bool File::isExecutable() | |
| 121 | { | |
| 122 | #warning implement | |
| 123 | } | |
| 124 | ||
| 125 | ||
| 126 | bool File::copy(const File& destination) | |
| 127 | { | |
| 128 | #warning implement | |
| 129 | } | |
| 130 | bool File::rename(const File& destination) | |
| 131 | { | |
| 132 | #warning implement | |
| 133 | } | |
| 134 | bool File::touch() | |
| 135 | { | |
| 136 | #warning implement | |
| 137 | } | |
| 138 | bool File::remove() | |
| 139 | { | |
| 140 | #warning implement | |
| 141 | } | |
| 142 | ||
| 143 | void File::relToAbs(std::string& fileName) | |
| 144 | { | |
| 145 | #warning implement | |
| 146 | } | |
| 147 | void File::absToRel(std::string& fileName) | |
| 148 | { | |
| 149 | #warning implement | |
| 150 | } | |
| 151 | ||
| 152 | ||
| 153 | ||
| 154 | ||
| 155 | std::string File::_cwd = ""; | |
| 156 | ||
| 157 | /** | |
| 158 | * @returns the Current Woring Directory | |
| 159 | */ | |
| 160 | const std::string& File::cwd() | |
| 161 | { | |
| 162 | if (File::_cwd.empty()) | |
| 163 | { | |
| 164 | char cwd[1024]; | |
| 165 | char* errorCode = getcwd(cwd, 1024); | |
| 166 | if (errorCode == 0) | |
| 167 | return File::_cwd; | |
| 168 | ||
| 169 | File::_cwd = cwd; | |
| 170 | } | |
| 171 | return File::_cwd; | |
| 172 | } | |
| 173 | ||
| 174 | ||
| 175 | ||
| 176 | #include "file.h" | |
| 177 | ||
| 178 |
Note: See TracBrowser
for help on using the repository browser.










