Path_VMS.cpp
Go to the documentation of this file.
00001 //
00002 // Path_VMS.cpp
00003 //
00004 // $Id: //poco/1.3/Foundation/src/Path_VMS.cpp#1 $
00005 //
00006 // Library: Foundation
00007 // Package: Filesystem
00008 // Module:  Path
00009 //
00010 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
00011 // and Contributors.
00012 //
00013 // Permission is hereby granted, free of charge, to any person or organization
00014 // obtaining a copy of the software and accompanying documentation covered by
00015 // this license (the "Software") to use, reproduce, display, distribute,
00016 // execute, and transmit the Software, and to prepare derivative works of the
00017 // Software, and to permit third-parties to whom the Software is furnished to
00018 // do so, all subject to the following:
00019 // 
00020 // The copyright notices in the Software and this entire statement, including
00021 // the above license grant, this restriction and the following disclaimer,
00022 // must be included in all copies of the Software, in whole or in part, and
00023 // all derivative works of the Software, unless such copies or derivative
00024 // works are solely in the form of machine-executable object code generated by
00025 // a source language processor.
00026 // 
00027 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00028 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00029 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00030 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00031 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00032 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00033 // DEALINGS IN THE SOFTWARE.
00034 //
00035 
00036 
00037 #include "Poco/Path_VMS.h"
00038 #include "Poco/Environment_VMS.h"
00039 #include <unistd.h>
00040 #include <descrip.h>
00041 #include <dvsdef.h>
00042 #include <dcdef.h>
00043 #include <iledef.h>
00044 #include <gen64def.h>
00045 #include <starlet.h>
00046 
00047 
00048 namespace Poco {
00049 
00050 
00051 std::string PathImpl::currentImpl()
00052 {
00053         std::string path;
00054         char cwd[PATH_MAX];
00055         if (getcwd(cwd, sizeof(cwd)))
00056                 path = cwd;
00057         else
00058                 throw SystemException("cannot get current directory");
00059         return path;
00060 }
00061 
00062 
00063 std::string PathImpl::homeImpl()
00064 {
00065         return EnvironmentImpl::trnlnm("SYS$LOGIN");
00066 }
00067 
00068 
00069 std::string PathImpl::tempImpl()
00070 {
00071         std::string result = EnvironmentImpl::trnlnm("SYS$SCRATCH");
00072         if (result.empty())
00073                 return homeImpl();
00074         else
00075                 return result; 
00076 }
00077 
00078 
00079 std::string PathImpl::nullImpl()
00080 {
00081         return "NLA0:";
00082 }
00083 
00084 
00085 std::string PathImpl::expandImpl(const std::string& path)
00086 {
00087         std::string result = path;
00088         std::string::const_iterator it  = result.begin();
00089         std::string::const_iterator end = result.end();
00090         int n = 0;
00091         while (it != end && n < 10)
00092         {
00093                 std::string logical;
00094                 while (it != end && *it != ':') logical += *it++;
00095                 if (it != end)
00096                 {
00097                         ++it;
00098                         if (it != end && *it == ':') return result;
00099                         std::string val = EnvironmentImpl::trnlnm(logical);
00100                         if (val.empty())
00101                                 return result;
00102                         else
00103                                 result = val + std::string(it, end);
00104                         it  = result.begin();
00105                         end = result.end();
00106                         ++n;
00107                 }
00108         }
00109         return result;
00110 }
00111 
00112 
00113 void PathImpl::listRootsImpl(std::vector<std::string>& roots)
00114 {
00115         char device[64];
00116         $DESCRIPTOR(deviceDsc, device);
00117         int clss = DC$_DISK;
00118         ILE3 items[2];
00119         items[0].ile3$w_code         = DVS$_DEVCLASS;
00120         items[0].ile3$w_length       = sizeof(clss);
00121         items[0].ile3$ps_bufaddr     = &clss;
00122         items[0].ile3$ps_retlen_addr = 0;
00123         items[1].ile3$w_code         = 0;
00124         items[1].ile3$w_length       = 0;
00125         int stat;
00126         GENERIC_64 context;
00127         context.gen64$q_quadword = 0;
00128         do 
00129         {
00130                 unsigned short length;
00131                 stat = sys$device_scan(&deviceDsc, &length, 0, &items, &context);
00132                 if (stat == SS$_NORMAL) 
00133                         roots.push_back(std::string(device, length));
00134         }
00135         while (stat == SS$_NORMAL);
00136 }
00137 
00138 
00139 } // namespace Poco


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:19