| [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 | |
|---|
| [7611] | 18 | #ifdef __unix__ |
|---|
| 19 | #include <unistd.h> |
|---|
| 20 | #elif __WIN32__ || _MS_DOS_ |
|---|
| 21 | #include <dir.h> |
|---|
| 22 | #else |
|---|
| 23 | #include <direct.h> |
|---|
| 24 | #endif |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | File::File() |
|---|
| 29 | { |
|---|
| 30 | #warning implement |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | File::File(const std::string& fileName) |
|---|
| 34 | { |
|---|
| 35 | #warning implement |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | File::File(const File& file) |
|---|
| 39 | { |
|---|
| 40 | #warning implement |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | File::~File() |
|---|
| 44 | { |
|---|
| 45 | #warning implement |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | bool File::open(OpenMode mode) |
|---|
| 49 | { |
|---|
| 50 | #warning implement |
|---|
| 51 | } |
|---|
| 52 | bool File::close() |
|---|
| 53 | { |
|---|
| 54 | #warning implement |
|---|
| 55 | } |
|---|
| 56 | int File::handle() |
|---|
| 57 | { |
|---|
| 58 | #warning implement |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | bool File::exists() |
|---|
| 62 | { |
|---|
| 63 | #warning implement |
|---|
| 64 | } |
|---|
| 65 | bool File::isLink() |
|---|
| 66 | { |
|---|
| 67 | #warning implement |
|---|
| 68 | } // only on UNIX |
|---|
| 69 | bool File::isFile() |
|---|
| 70 | { |
|---|
| 71 | #warning implement |
|---|
| 72 | } |
|---|
| 73 | bool File::isDirectory() |
|---|
| 74 | { |
|---|
| [7612] | 75 | std::string tmpDirName = this->_name; |
|---|
| 76 | struct stat status; |
|---|
| 77 | |
|---|
| 78 | // checking for the termination of the string given. If there is a "/" at the end cut it away |
|---|
| 79 | if (directoryName[directoryName.size()-1] == '/' || |
|---|
| 80 | directoryName[directoryName.size()-1] == '\\') |
|---|
| 81 | { |
|---|
| 82 | tmpDirName.erase(tmpDirName.size()-1); |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | if(!stat(tmpDirName.c_str(), &status)) |
|---|
| 86 | { |
|---|
| 87 | if (status.st_mode & (S_IFDIR |
|---|
| 88 | #ifndef __WIN32__ |
|---|
| 89 | | S_IFLNK |
|---|
| 90 | #endif |
|---|
| 91 | )) |
|---|
| 92 | { |
|---|
| 93 | return true; |
|---|
| 94 | } |
|---|
| 95 | else |
|---|
| 96 | return false; |
|---|
| 97 | } |
|---|
| 98 | else |
|---|
| 99 | return false; |
|---|
| [7611] | 100 | } |
|---|
| [7612] | 101 | |
|---|
| [7611] | 102 | bool File::isReadeable() |
|---|
| 103 | { |
|---|
| [7612] | 104 | |
|---|
| [7611] | 105 | #warning implement |
|---|
| 106 | } |
|---|
| [7612] | 107 | |
|---|
| [7611] | 108 | bool File::isWriteable() |
|---|
| 109 | { |
|---|
| 110 | #warning implement |
|---|
| 111 | } |
|---|
| 112 | bool File::isExecutable() |
|---|
| 113 | { |
|---|
| 114 | #warning implement |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | bool File::copy(const File& destination) |
|---|
| 119 | { |
|---|
| 120 | #warning implement |
|---|
| 121 | } |
|---|
| 122 | bool File::rename(const File& destination) |
|---|
| 123 | { |
|---|
| 124 | #warning implement |
|---|
| 125 | } |
|---|
| 126 | bool File::touch() |
|---|
| 127 | { |
|---|
| 128 | #warning implement |
|---|
| 129 | } |
|---|
| 130 | bool File::remove() |
|---|
| 131 | { |
|---|
| 132 | #warning implement |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | void File::relToAbs(std::string& fileName) |
|---|
| 136 | { |
|---|
| 137 | #warning implement |
|---|
| 138 | } |
|---|
| 139 | void File::absToRel(std::string& fileName) |
|---|
| 140 | { |
|---|
| 141 | #warning implement |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | std::string File::_cwd = ""; |
|---|
| 148 | |
|---|
| 149 | /** |
|---|
| 150 | * @returns the Current Woring Directory |
|---|
| 151 | */ |
|---|
| 152 | const std::string& File::cwd() |
|---|
| 153 | { |
|---|
| 154 | if (File::_cwd.empty()) |
|---|
| 155 | { |
|---|
| 156 | char cwd[1024]; |
|---|
| 157 | char* errorCode = getcwd(cwd, 1024); |
|---|
| 158 | if (errorCode == 0) |
|---|
| 159 | return File::_cwd; |
|---|
| 160 | |
|---|
| 161 | File::_cwd = cwd; |
|---|
| 162 | } |
|---|
| 163 | return File::_cwd; |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | #include "file.h" |
|---|
| 169 | |
|---|
| 170 | |
|---|