 |
Changeset 3386
- Timestamp:
- 03/21/08 04:44:05
(9 months ago)
- Author:
- lmartin92
- Message:
Fixed it to compile but figured out some changes needed to be made to FtpFolders? so will work on them.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3383 |
r3386 |
|
| 6 | 6 | */ |
|---|
| 7 | 7 | |
|---|
| | 8 | //fix flatness |
|---|
| | 9 | |
|---|
| 8 | 10 | import tango.net.ftp.FtpClient; |
|---|
| 9 | 11 | import tango.io.vfs.model.Vfs; |
|---|
| | 12 | import tango.io.vfs.FileFolder; |
|---|
| 10 | 13 | import tango.io.Conduit; |
|---|
| 11 | 14 | import tango.text.Util; |
|---|
| … | … | |
| 104 | 107 | |
|---|
| 105 | 108 | VfsFolders self() { |
|---|
| 106 | | return new VfsFolders(toString_, name_, username_, password_, port_, |
|---|
| | 109 | return new FtpFolders(toString_, name_, username_, password_, port_, |
|---|
| 107 | 110 | true); |
|---|
| 108 | 111 | } |
|---|
| 109 | 112 | |
|---|
| 110 | 113 | VfsFolders tree() { |
|---|
| 111 | | return new VfsFolders(toString_, name_, username_, password_, port_, |
|---|
| | 114 | return new FtpFolders(toString_, name_, username_, password_, port_, |
|---|
| 112 | 115 | false); |
|---|
| 113 | 116 | } |
|---|
| … | … | |
| 122 | 125 | |
|---|
| 123 | 126 | foreach(FtpFileInfo fi; fis) { |
|---|
| 124 | | if(fi.type = FtpFileType.dir) { |
|---|
| 125 | | FtpFolder x = new FtpFolder(toString_, fi.name, username_, |
|---|
| | 127 | if(fi.type == FtpFileType.dir) { |
|---|
| | 128 | VfsFolder x = new FtpFolder(toString_, fi.name, username_, |
|---|
| 126 | 129 | password_, port_); |
|---|
| 127 | 130 | if((result = dg(x)) != 0) |
|---|
| … | … | |
| 177 | 180 | char[] toString_, name_, username_, password_; |
|---|
| 178 | 181 | uint port_; |
|---|
| | 182 | bool flat_; |
|---|
| 179 | 183 | |
|---|
| 180 | 184 | public this(char[] server, char[] path, char[] username = "anonymous", |
|---|
| … | … | |
| 188 | 192 | body { |
|---|
| 189 | 193 | toString_ = server; |
|---|
| 190 | | name_ = name != "" ? path : server; |
|---|
| 191 | | username_ = username; |
|---|
| 192 | | password_ = password; |
|---|
| 193 | | port_ = port; |
|---|
| | 194 | name_ = path != "" ? path : server; |
|---|
| | 195 | username_ = username; |
|---|
| | 196 | password_ = password; |
|---|
| | 197 | port_ = port; |
|---|
| | 198 | } |
|---|
| | 199 | |
|---|
| | 200 | public this(char[] server, char[] path, char[] username = "anonymous", |
|---|
| | 201 | char[] password = "anonymous@anonymous", uint port = 21, bool flat = false) |
|---|
| | 202 | in { |
|---|
| | 203 | assert(server != ""); |
|---|
| | 204 | } |
|---|
| | 205 | out { |
|---|
| | 206 | assert(server != ""); |
|---|
| | 207 | } |
|---|
| | 208 | body { |
|---|
| | 209 | toString_ = server; |
|---|
| | 210 | name_ = path != "" ? path : server; |
|---|
| | 211 | username_ = username; |
|---|
| | 212 | password_ = password; |
|---|
| | 213 | port_ = port; |
|---|
| | 214 | flat_ = flat; |
|---|
| 194 | 215 | } |
|---|
| 195 | 216 | |
|---|
| 196 | 217 | int opApply(int delegate(inout VfsFolder) dg) { |
|---|
| 197 | | FtpFolder ftp = new FtpFolder(toString_, name_, username, password_, |
|---|
| | 218 | FtpFolder ftp = new FtpFolder(toString_, name_, username_, password_, |
|---|
| 198 | 219 | port_); |
|---|
| 199 | | ftp.opApply(dg); |
|---|
| | 220 | return ftp.opApply(dg); |
|---|
| 200 | 221 | } |
|---|
| 201 | 222 | |
|---|
| … | … | |
| 208 | 229 | |
|---|
| 209 | 230 | foreach(FtpFileInfo fi; fis) { |
|---|
| 210 | | if(fi.type == FtpFileType.unknown || fi.type == FTPFileType.file || fi.type == FtpFileType.other) |
|---|
| | 231 | if(fi.type == FtpFileType.unknown || fi.type == FtpFileType.file || fi.type == FtpFileType.other) |
|---|
| 211 | 232 | size++; |
|---|
| 212 | 233 | } |
|---|
| … | … | |
| 223 | 244 | |
|---|
| 224 | 245 | foreach(FtpFileInfo fi; fis) { |
|---|
| 225 | | if(fi.type != FtpFileType.unknown || fi.type != FTPFileType.file || fi.type != FtpFileType.other) |
|---|
| | 246 | if(fi.type != FtpFileType.unknown || fi.type != FtpFileType.file || fi.type != FtpFileType.other) |
|---|
| 226 | 247 | size++; |
|---|
| 227 | 248 | } |
|---|
| … | … | |
| 242 | 263 | |
|---|
| 243 | 264 | foreach(FtpFileInfo fi; fis) { |
|---|
| 244 | | if(fi.type == FtpFileType.unknown || fi.type == FTPFileType.file || fi.type == FtpFileType.other) |
|---|
| | 265 | if(fi.type == FtpFileType.unknown || fi.type == FtpFileType.file || fi.type == FtpFileType.other) |
|---|
| 245 | 266 | size += fi.size; |
|---|
| 246 | 267 | } |
|---|
| … | … | |
| 257 | 278 | return new FtpFiles(toString_, name_, username_, password_, port_, |
|---|
| 258 | 279 | filter); |
|---|
| | 280 | } |
|---|
| | 281 | |
|---|
| | 282 | VfsFolders subset (char[] pattern){ |
|---|
| | 283 | return null; |
|---|
| 259 | 284 | } |
|---|
| 260 | 285 | } |
|---|
| … | … | |
| 311 | 336 | |
|---|
| 312 | 337 | VfsFile copy(VfsFile source) { |
|---|
| 313 | | output.write(source.input.read); |
|---|
| | 338 | void[] dest; |
|---|
| | 339 | source.input.read(dest); |
|---|
| | 340 | output.write(dest); |
|---|
| | 341 | return new FtpFile(toString_, name_, username_, password_, port_); |
|---|
| 314 | 342 | } |
|---|
| 315 | 343 | |
|---|
| … | … | |
| 317 | 345 | copy(source); |
|---|
| 318 | 346 | source.remove; |
|---|
| | 347 | return new FtpFile(toString_, name_, username_, password_, port_); |
|---|
| 319 | 348 | } |
|---|
| 320 | 349 | |
|---|
| 321 | 350 | VfsFile create() { |
|---|
| 322 | | FileFolder ff = new FileFolder("/NF", true); |
|---|
| | 351 | VfsFolder f = new FileFolder(""); |
|---|
| | 352 | VfsFile ff = f.file("/NF.NF"); |
|---|
| 323 | 353 | ftp_ = new FTPConnection(); |
|---|
| 324 | 354 | ftp_.connect(toString_, username_, password_, port_); |
|---|
| 325 | 355 | ftp_.put(name_, ff.input); |
|---|
| 326 | | ftp.close(); |
|---|
| | 356 | ftp_.close(); |
|---|
| 327 | 357 | ff.remove(); |
|---|
| 328 | 358 | return new FtpFile(toString_, name_, username_, password_, port_); |
|---|
| … | … | |
| 333 | 363 | ftp_.connect(toString_, username_, password_, port_); |
|---|
| 334 | 364 | ftp_.put(name_, stream); |
|---|
| 335 | | ftp.close(); |
|---|
| | 365 | ftp_.close(); |
|---|
| 336 | 366 | return new FtpFile(toString_, name_, username_, password_, port_); |
|---|
| 337 | 367 | } |
|---|
| … | … | |
| 341 | 371 | ftp_.connect(toString_, username_, password_, port_); |
|---|
| 342 | 372 | ftp_.del(name_); |
|---|
| 343 | | return new VfsFile(toString_, name_, username_, password_, port_); |
|---|
| | 373 | return new FtpFile(toString_, name_, username_, password_, port_); |
|---|
| 344 | 374 | } |
|---|
| 345 | 375 | |
|---|
| 346 | 376 | InputStream input() { |
|---|
| 347 | | ftp_ = new FtpConnection(); |
|---|
| | 377 | ftp_ = new FTPConnection(); |
|---|
| 348 | 378 | ftp_.connect(toString_, username_, password_, port_); |
|---|
| 349 | 379 | InputStream input = ftp_.input; |
|---|
| 350 | | prepareInputStream(ftp_, input, FtpCommand.RETR, ["", path_]); |
|---|
| | 380 | prepareInputStream(ftp_, input, FtpCommand.RETR, ["", name_]); |
|---|
| 351 | 381 | ftp_.close(); |
|---|
| 352 | 382 | return input; |
|---|
| … | … | |
| 354 | 384 | |
|---|
| 355 | 385 | OutputStream output() { |
|---|
| 356 | | ftp_ = new FtpConnection(); |
|---|
| | 386 | ftp_ = new FTPConnection(); |
|---|
| 357 | 387 | ftp_.connect(toString_, username_, password_, port_); |
|---|
| 358 | 388 | OutputStream output = ftp_.output; |
|---|
| 359 | | prepareOutputStream(ftp_, output, FtpCommand.STOR, ["", path_]); |
|---|
| | 389 | prepareOutputStream(ftp_, output, FtpCommand.STOR, ["", name_]); |
|---|
| 360 | 390 | ftp_.close(); |
|---|
| 361 | 391 | return output; |
|---|
| … | … | |
| 389 | 419 | body { |
|---|
| 390 | 420 | toString_ = server; |
|---|
| 391 | | name_ = name != "" ? path : server; |
|---|
| | 421 | name_ = path != "" ? path : server; |
|---|
| 392 | 422 | username_ = username; |
|---|
| 393 | 423 | password_ = password; |
|---|
| … | … | |
| 409 | 439 | body { |
|---|
| 410 | 440 | toString_ = server; |
|---|
| 411 | | name_ = name != "" ? path : server; |
|---|
| | 441 | name_ = path != "" ? path : server; |
|---|
| 412 | 442 | username_ = username; |
|---|
| 413 | 443 | password_ = password; |
|---|
| … | … | |
| 419 | 449 | int result; |
|---|
| 420 | 450 | foreach(FtpFileInfo inf; getFileInfo()) { |
|---|
| 421 | | FtpFile x = new FtpFile(toString_, inf.name, username_, password_, |
|---|
| 422 | | port); |
|---|
| | 451 | VfsFile x = new FtpFile(toString_, inf.name, username_, password_, |
|---|
| | 452 | port_); |
|---|
| 423 | 453 | if((result = dg(x)) != 0) |
|---|
| 424 | 454 | break; |
|---|
| … | … | |
| 436 | 466 | FtpFileInfo[] infs = ftp_.ls(); |
|---|
| 437 | 467 | FtpFileInfo[] toReturn; |
|---|
| 438 | | if(useFilter) { |
|---|
| | 468 | if(useFilter_) { |
|---|
| 439 | 469 | foreach(FtpFileInfo inf; infs) { |
|---|
| 440 | | if(contains(inf.name, filter_)) { |
|---|
| | 470 | if(containsPattern(inf.name, filter_)) { |
|---|
| 441 | 471 | toReturn ~= inf; |
|---|
| 442 | 472 | } |
|---|
| … | … | |
| 447 | 477 | VfsFilterInfo temp; |
|---|
| 448 | 478 | temp.name = inf.name; |
|---|
| 449 | | temp.folder = toString_; |
|---|
| | 479 | temp.folder = false; |
|---|
| 450 | 480 | temp.path = toString_ ~ temp.name; |
|---|
| 451 | 481 | temp.bytes = inf.size; |
|---|
Download in other formats:
|
 |