X-Git-Url: http://git.home-dn.net/?p=manu%2Fsuphp.git;a=blobdiff_plain;f=src%2FFile.cpp;h=d5183f3159fe0b3f59d2b28cc571d284e719929a;hp=6c6d303d4b4d548c31539351f5b63cb220656ee2;hb=849f4a7977b5780eacae8fad7a078d05f4a615ee;hpb=b0eaa3f1fbf491fdc8a3044cf20754f14254338a diff --git a/src/File.cpp b/src/File.cpp index 6c6d303..d5183f3 100644 --- a/src/File.cpp +++ b/src/File.cpp @@ -1,5 +1,5 @@ /* - suPHP - (c)2002-2005 Sebastian Marsching + suPHP - (c)2002-2008 Sebastian Marsching This file is part of suPHP. @@ -36,12 +36,12 @@ std::string suPHP::File::getPath() const{ return this->path; } -SmartPtr suPHP::File::getInputStream() throw (IOException) { +SmartPtr suPHP::File::getInputStream() const throw (IOException) { std::ifstream* infile = new std::ifstream(); infile->open(this->path.c_str()); if (infile->bad() || infile->fail()) { - throw IOException("Could not open file " + - this->path + " for reading", __FILE__, __LINE__); + throw IOException("Could not open file " + + this->path + " for reading", __FILE__, __LINE__); } return SmartPtr(infile); } @@ -57,6 +57,9 @@ std::string suPHP::File::getRealPath() const throw (SystemException) { File suPHP::File::getParentDirectory() const { std::string path = this->getPath(); path = path.substr(0, path.rfind('/')); + if (path.length() == 0) { + path = "/"; + } return File(path); } @@ -104,3 +107,8 @@ UserInfo suPHP::File::getUser() const throw (SystemException) { GroupInfo suPHP::File::getGroup() const throw (SystemException) { return API_Helper::getSystemAPI().File_getGroup(*this); } + + +bool suPHP::File::isSymlink() const throw (SystemException) { + return API_Helper::getSystemAPI().File_isSymlink(*this); +}