Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changes between Version 16 and Version 17 of ChapterVFS

Show
Ignore:
Author:
lmartin92 (IP: 66.175.144.84)
Timestamp:
03/28/09 14:04:34 (6 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ChapterVFS

    v16 v17  
    366366== !FtpFolder == 
    367367 
     368This driver manages passive FTP connections. It allows for the treatment of a FTP folder as if were locally mounted, excluding the intialization phase of a FTP folder. When creating an instance of any of the classes in the FTP VFS adapter, all that is required is for the server name, and the path name to be provided. The server name is the name of the FTP server, and the path name is a name of a path, or a name of a file. The server name will not work with "ftp://x.com" but only works like "x.com". The path name works where all that has to be provided is the name of the path or file residing on the server. For example, the name of a path could be "/directory" and the name of a file "/directory/filename". This VFS driver has some non-standard features which will be noted later, especially the part telling of how to access these features. They are part of a proposed standard that is not implemented up to this point but can be implemented though. This driver works around some common problems that can occur in a connection to a FTP server. For instance, some servers only allow a certain number of concurrent connections at one point in time. To keep from encountering this limit, this implementation connects per method called such that almost any call to any function in this driver will result in a new connection, and the closing of that connection after the information needed is gained. However, it is done a bit differently in the FtpFile class so as to allow reading and writing of large content without sitting in the method all day. In the FtpFile class, it keeps around it's connection until it is finished writing. The reasons behind this are too complex to be written out in this document. 
     369 
     370Creating a connection is as simple as 
     371 
     372{{{ 
     373#!d 
     374auto entry = new FtpFolderEntry("ftp.nameofserver.com", "/directory", "username", "password", 21); 
     375}}} 
     376 
     377Note that the last 3 arguments are completely optional. Those set of arguments are pretty much available for use on every class in the FTP VFS adapter. 
     378 
     379To access a file, using the entry we created above, all that has to be done is, first open the folder, then ask the folder to open the file as the following example shows. 
     380 
     381{{{ 
     382#!d 
     383auto folder = entry.open(); 
     384auto file = folder.file("filename"); 
     385}}} 
     386 
     387Do note that is is usually good practice to check for the existence of a folder and if it isn't there, and it is wanted there, it is best to create it. To do the check and create the following example is provided. 
     388 
     389{{{ 
     390#!d 
     391if(!entry.exists()) 
     392    entry.create(); 
     393}}} 
     394 
     395The same can be done to a file. 
     396 
     397{{{ 
     398#!d 
     399if(!file.exists()) 
     400    file.create; 
     401}}} 
     402 
     403Now we have accessed a file at "ftp.nameofserver.com/directory/filename" assuming that that place is actually in existence. Do note however that it is impossible to create "ftp.nameofserver.com" through programming; to do that, one would have to physically buy the domain and much more that is past the scope of this document. Just note that this can not be done through programming. 
     404 
     405This is some of the basic set of functionality. To learn more, one could read the documentation, or read the code (latter is preffered). Just look at the function signatures as they are pretty understandable, self-explanatory, and work a lot like most other drivers. 
     406 
     407Now we have got to the point at which non-standard driver features will be discussed. As they are not yet available in the standard interfaces, it will have to be done by directly using the FTP VFS Adapter classes. Basically, no "auto that = new that();" stuff. The only non-standard driver options provided are some time functions. They are part of a proposal and apparently the author of the code decided to pre-implement them so as to save himself some work in the future. To access these proposed functions all that has to be done is: 
     408 
     409{{{ 
     410#!d 
     411FtpFile file = new FtpFile("ftp.nameofserver.com", "/directory/filename", "username", "password", 21"); 
     412//initialize a file to connect to at ftp.nameofserver.com/directory/filename 
     413auto time = file.mtime(); 
     414auto time2 = file.ctime(); 
     415auto time3 = file.atime(); 
     416}}} 
     417 
     418mtime() and atime() are the same as the functionality requested is not available in the FTP standard and this was the closest the author could get to it. mtime() is for time modified (as is atime()) and ctime() is for time created.  
     419 
     420This is the basics, happy coding!. 
     421 
    368422== !WebDavFolder == 
    369423