00001 // This is core/vul/vul_url.h 00002 #ifndef vul_url_h_ 00003 #define vul_url_h_ 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 //: 00008 // \file 00009 // \brief Static class methods to test and open streams via a URL 00010 // \author Ian Scott 00011 // Based on vil_stream_url by fsm 00012 // \verbatim 00013 // Modifications 00014 // 8 Nov 2002 - Peter Vanroose - corrected HTTP client request syntax 00015 // \endverbatim 00016 00017 #include <vcl_istream.h> 00018 #include <vcl_iostream.h> // needed for vcl_ios_in and vcl_ios_openmode 00019 #include <vcl_string.h> 00020 00021 //: Functions to test and open streams via a URL 00022 // Currently supports file and HTTP only. 00023 // HTTP support includes basic authentication, using the normal 00024 // HTTP URL scheme, e.g. \c http://user4:mypassword@webserverthingy.org/file.txt 00025 class vul_url 00026 { 00027 public: 00028 //: open a URL 00029 // If URL is "file://..." open as a file with given mode. 00030 // If URL is "http://..." open using vul_http_open 00031 // If URL is "ftp://..." attempt ftp 00032 // Otherwise assume it is a filename and open with given mode 00033 static vcl_istream* open(const char* url, vcl_ios_openmode mode=vcl_ios_in ); 00034 00035 //: Does that URL exist 00036 // If the URL does not begin with a recognised scheme identifier, the function will 00037 // treat the parameter as a local filename 00038 static bool exists(const char* url); 00039 00040 //: Is that a URL 00041 // as opposed to an ordinary filename. 00042 static bool is_url(const char* url); 00043 00044 //: Is that a file 00045 // i.e. is it a downloadable URL, or a file on disk that isn't a directory. 00046 static bool is_file(const char* url); 00047 00048 //: Encode a string of chars into base64 format 00049 static vcl_string encode_base64(const vcl_string& in); 00050 00051 //: Decode a string of chars from base64 format 00052 static vcl_string decode_base64(const vcl_string& in); 00053 }; 00054 00055 #endif // vul_url_h_