 |
Changeset 3377
- Timestamp:
- 03/17/08 21:19:41
(9 months ago)
- Author:
- lmartin92
- Message:
Updated to get the final Folder part of FtpFolder?.d implemented. A bit of FtpFile? is implemented. All constructors minus one are implemented. Need to finish FtpFiles? and FtpFile?, add comments, and maybe rearange stuff to make the code more clear or for other reasons
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3372 |
r3377 |
|
| 17 | 17 | |
|---|
| 18 | 18 | public this(char[] server, char[] path, char[] username = "anonymous", |
|---|
| 19 | | char[] password = "anonymous@anonymous", uint port = 21) |
|---|
| | 19 | char[] password = "anonymous@anonymous", uint port = 21) |
|---|
| 20 | 20 | in { |
|---|
| 21 | 21 | assert(server != ""); |
|---|
| … | … | |
| 71 | 71 | |
|---|
| 72 | 72 | public this(char[] server, char[] path, char[] username = "anonymous", |
|---|
| 73 | | char[] password = "anonymous@anonymous", uint port = 21) |
|---|
| | 73 | char[] password = "anonymous@anonymous", uint port = 21) |
|---|
| 74 | 74 | in { |
|---|
| 75 | 75 | assert(server != ""); |
|---|
| … | … | |
| 104 | 104 | VfsFolders self() { |
|---|
| 105 | 105 | return new VfsFolders(toString_, name_, username_, password_, port_, |
|---|
| 106 | | true); |
|---|
| | 106 | true); |
|---|
| 107 | 107 | } |
|---|
| 108 | 108 | |
|---|
| 109 | 109 | VfsFolders tree() { |
|---|
| 110 | 110 | return new VfsFolders(toString_, name_, username_, password_, port_, |
|---|
| 111 | | false); |
|---|
| | 111 | false); |
|---|
| 112 | 112 | } |
|---|
| 113 | 113 | |
|---|
| … | … | |
| 123 | 123 | if(fi.type = FtpFileType.dir) { |
|---|
| 124 | 124 | FtpFolder x = new FtpFolder(toString_, fi.name, username_, |
|---|
| 125 | | password_, port_); |
|---|
| | 125 | password_, port_); |
|---|
| 126 | 126 | if((result = dg(x)) != 0) |
|---|
| 127 | 127 | break; |
|---|
| … | … | |
| 178 | 178 | |
|---|
| 179 | 179 | public this(char[] server, char[] path, char[] username = "anonymous", |
|---|
| 180 | | char[] password = "anonymous@anonymous", uint port = 21) |
|---|
| | 180 | char[] password = "anonymous@anonymous", uint port = 21) |
|---|
| 181 | 181 | in { |
|---|
| 182 | 182 | assert(server != ""); |
|---|
| … | … | |
| 195 | 195 | int opApply(int delegate(inout VfsFolder) dg) { |
|---|
| 196 | 196 | FtpFolder ftp = new FtpFolder(toString_, name_, username, password_, |
|---|
| 197 | | port_); |
|---|
| | 197 | port_); |
|---|
| 198 | 198 | ftp.opApply(dg); |
|---|
| 199 | 199 | } |
|---|
| … | … | |
| 250 | 250 | VfsFiles catalog(char[] pattern) { |
|---|
| 251 | 251 | return new FtpFiles(toString_, name_, username_, password_, port_, |
|---|
| 252 | | pattern); |
|---|
| | 252 | pattern); |
|---|
| 253 | 253 | } |
|---|
| 254 | 254 | |
|---|
| 255 | 255 | VfsFiles catalog(VfsFilter filter = null) { |
|---|
| 256 | 256 | return new FtpFiles(toString_, name_, username_, password_, port_, |
|---|
| 257 | | filter); |
|---|
| | 257 | filter); |
|---|
| 258 | 258 | } |
|---|
| 259 | 259 | } |
|---|
| 260 | 260 | |
|---|
| 261 | 261 | class FtpFile: VfsFile { |
|---|
| | 262 | |
|---|
| | 263 | FTPConnection ftp_; |
|---|
| | 264 | char[] toString_, name_, username_, password_; |
|---|
| | 265 | uint port_; |
|---|
| | 266 | bool writeable_, writeableSet_; |
|---|
| | 267 | |
|---|
| | 268 | public this(char[] server, char[] path, char[] username = "anonymous", |
|---|
| | 269 | char[] password = "anonymous@anonymous", uint port = 21) |
|---|
| | 270 | in { |
|---|
| | 271 | assert(server != ""); |
|---|
| | 272 | } |
|---|
| | 273 | out { |
|---|
| | 274 | assert(server != ""); |
|---|
| | 275 | } |
|---|
| | 276 | body { |
|---|
| | 277 | toString_ = server; |
|---|
| | 278 | name_ = name != "" ? path : server; |
|---|
| | 279 | username_ = username; |
|---|
| | 280 | password_ = password; |
|---|
| | 281 | port_ = port; |
|---|
| | 282 | } |
|---|
| | 283 | |
|---|
| 262 | 284 | char[] name() { |
|---|
| 263 | | return null; |
|---|
| | 285 | return name_; |
|---|
| 264 | 286 | } |
|---|
| 265 | 287 | |
|---|
| 266 | 288 | char[] toString() { |
|---|
| 267 | | return null; |
|---|
| | 289 | return toString_ ~ '/' ~ name_; |
|---|
| 268 | 290 | } |
|---|
| 269 | 291 | |
|---|
| 270 | 292 | bool exists() { |
|---|
| 271 | | return null; |
|---|
| | 293 | ftp_ = new FTPConnection(); |
|---|
| | 294 | ftp_.connect(toString_, username_, password_, port_); |
|---|
| | 295 | bool result = ftp_.exist(name_) == 1 ? true : false; |
|---|
| | 296 | ftp_.close(); |
|---|
| | 297 | return result; |
|---|
| 272 | 298 | } |
|---|
| 273 | 299 | |
|---|
| 274 | 300 | ulong size() { |
|---|
| 275 | | return null; |
|---|
| | 301 | ulong result = 0; |
|---|
| | 302 | if(exists()) { |
|---|
| | 303 | ftp_ = new FTPConnection(); |
|---|
| | 304 | ftp_.connect(toString_, username_, password_, port_); |
|---|
| | 305 | result = ftp_.getFileInfo(name_).size; |
|---|
| | 306 | ftp_.close(); |
|---|
| | 307 | } |
|---|
| | 308 | return result; |
|---|
| 276 | 309 | } |
|---|
| 277 | 310 | |
|---|
| … | … | |
| 310 | 343 | |
|---|
| 311 | 344 | class FtpFiles: VfsFiles { |
|---|
| | 345 | |
|---|
| | 346 | FTPConnection ftp_; |
|---|
| | 347 | char[] toString_, name_, username_, password_; |
|---|
| | 348 | uint port_; |
|---|
| | 349 | bool writeable_, writeableSet_; |
|---|
| | 350 | char[] filter_; |
|---|
| | 351 | VfsFilter ffilter_; |
|---|
| | 352 | bool useFilter = false; |
|---|
| | 353 | |
|---|
| | 354 | public this(char[] server, char[] path, char[] username = "anonymous", |
|---|
| | 355 | char[] password = "anonymous@anonymous", uint port = 21, |
|---|
| | 356 | char[] filtPattern = "") |
|---|
| | 357 | in { |
|---|
| | 358 | assert(server != ""); |
|---|
| | 359 | } |
|---|
| | 360 | out { |
|---|
| | 361 | assert(server != ""); |
|---|
| | 362 | } |
|---|
| | 363 | body { |
|---|
| | 364 | toString_ = server; |
|---|
| | 365 | name_ = name != "" ? path : server; |
|---|
| | 366 | username_ = username; |
|---|
| | 367 | password_ = password; |
|---|
| | 368 | port_ = port; |
|---|
| | 369 | filter_ = filtPattern; |
|---|
| | 370 | useFilter = true; |
|---|
| | 371 | } |
|---|
| | 372 | |
|---|
| | 373 | public this(char[] server, char[] path, char[] username = "anonymous", |
|---|
| | 374 | char[] password = "anonymous@anonymous", uint port = 21, |
|---|
| | 375 | VfsFilter filter = null) |
|---|
| | 376 | in { |
|---|
| | 377 | assert(server != ""); |
|---|
| | 378 | } |
|---|
| | 379 | out { |
|---|
| | 380 | assert(server != ""); |
|---|
| | 381 | } |
|---|
| | 382 | body { |
|---|
| | 383 | toString_ = server; |
|---|
| | 384 | name_ = name != "" ? path : server; |
|---|
| | 385 | username_ = username; |
|---|
| | 386 | password_ = password; |
|---|
| | 387 | port_ = port; |
|---|
| | 388 | ffilter_ = filter; |
|---|
| | 389 | } |
|---|
| | 390 | |
|---|
| 312 | 391 | int opApply(int delegate(inout VfsFile) dg) { |
|---|
| 313 | 392 | return null; |
|---|
Download in other formats:
|
 |