Permalink
Browse files

[cleanup] - after first review

- removed unneeded header includes
- removed unused function
- some cosmetics
- removed usage of URIUtils::GetParentPath
  • Loading branch information...
1 parent 256a4aa commit 1bb1db519e248e8a9b572e33ca9a9757a9d4f583 @Memphiz committed Jun 12, 2011
Showing with 17 additions and 48 deletions.
  1. +4 −20 xbmc/filesystem/FileNFS.cpp
  2. +0 −2 xbmc/filesystem/FileNFS.h
  3. +13 −25 xbmc/filesystem/NFSDirectory.cpp
  4. +0 −1 xbmc/filesystem/NFSDirectory.h
View
24 xbmc/filesystem/FileNFS.cpp
@@ -27,24 +27,12 @@
#ifdef HAS_FILESYSTEM_NFS
#include "DllLibNfs.h"
#include "FileNFS.h"
-#include "NFSDirectory.h"
-#include "Util.h"
-#include "settings/AdvancedSettings.h"
-#include "settings/GUISettings.h"
#include "threads/SingleLock.h"
#include "utils/log.h"
-#include "utils/TimeUtils.h"
#include "utils/URIUtils.h"
using namespace XFILE;
-CStdString URLEncode(const CStdString value)
-{
- CStdString encoded(value);
- CURL::Encode(encoded);
- return encoded;
-}
-
CNfsConnection::CNfsConnection()
: m_pNfsContext(NULL)
, m_shareName("")
@@ -232,7 +220,7 @@ bool CFileNFS::Open(const CURL& url)
return false;
}
- CStdString filename = "/" + URIUtils::GetFileName(url.GetFileName());
+ CStdString filename = "//" + URIUtils::GetFileName(url.GetFileName());
CSingleLock lock(gNfsConnection);
@@ -270,11 +258,7 @@ bool CFileNFS::Open(const CURL& url)
bool CFileNFS::Exists(const CURL& url)
{
- CURL oldurl = m_url;
- m_url = url;
- bool ret = Stat(NULL) == 0;
- m_url = oldurl;
- return ret;
+ return Stat(url,NULL) == 0;
}
int CFileNFS::Stat(struct __stat64* buffer)
@@ -291,7 +275,7 @@ int CFileNFS::Stat(const CURL& url, struct __stat64* buffer)
if(!gNfsConnection.Connect(url))
return -1;
- CStdString filename = "/" + URIUtils::GetFileName(url.GetFileName());
+ CStdString filename = "//" + URIUtils::GetFileName(url.GetFileName());
struct stat tmpBuffer = {0};
@@ -360,7 +344,7 @@ unsigned int CFileNFS::Read(void *lpBuf, int64_t uiBufSize)
}
}
- return (unsigned int)numberOfBytesRead;
+ return (unsigned int)numberOfBytesRead;
}
int64_t CFileNFS::Seek(int64_t iFilePosition, int iWhence)
View
2 xbmc/filesystem/FileNFS.h
@@ -7,8 +7,6 @@
#include "URL.h"
#include "threads/CriticalSection.h"
-CStdString URLEncode(CStdString str);
-
class DllLibNfs;
class CNfsConnection : public CCriticalSection
View
38 xbmc/filesystem/NFSDirectory.cpp
@@ -24,12 +24,7 @@
#ifdef HAS_FILESYSTEM_NFS
#include "DllLibNfs.h"
#include "NFSDirectory.h"
-#include "Util.h"
-#include "guilib/LocalizeStrings.h"
-#include "Application.h"
#include "FileItem.h"
-#include "settings/AdvancedSettings.h"
-#include "utils/StringUtils.h"
#include "utils/log.h"
#include "utils/URIUtils.h"
#include "threads/SingleLock.h"
@@ -49,7 +44,7 @@ CNFSDirectory::~CNFSDirectory(void)
bool CNFSDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
- // We accept nfs://server/share/path[/file]]]]
+ // We accept nfs://server/path[/file]]]]
int ret = 0;
FILETIME fileTime, localTime;
CSingleLock lock(gNfsConnection);
@@ -142,17 +137,14 @@ bool CNFSDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items
bool CNFSDirectory::Create(const char* strPath)
{
int ret = 0;
- int newFolderLen = 0;
CSingleLock lock(gNfsConnection);
-
- CURL url(URIUtils::GetParentPath(strPath));
CStdString folderName(strPath);
- newFolderLen = folderName.length() - URIUtils::GetParentPath(strPath).length();
- folderName = "//" + folderName.Right(newFolderLen);
-
URIUtils::RemoveSlashAtEnd(folderName);//mkdir fails if a slash is at the end!!!
+ CURL url(folderName);
+ folderName = "//" + URIUtils::GetFileName(folderName);
+
if(!gNfsConnection.Connect(url))
return false;
@@ -166,17 +158,13 @@ bool CNFSDirectory::Create(const char* strPath)
bool CNFSDirectory::Remove(const char* strPath)
{
int ret = 0;
- int delFolderLen = 0;
CSingleLock lock(gNfsConnection);
-
- CURL url(URIUtils::GetParentPath(strPath));
CStdString folderName(strPath);
- delFolderLen = folderName.length() - URIUtils::GetParentPath(strPath).length();
- folderName = "//" + folderName.Right(delFolderLen);
-
URIUtils::RemoveSlashAtEnd(folderName);//rmdir fails if a slash is at the end!!!
+ CURL url(folderName);
+ folderName = "//" + URIUtils::GetFileName(folderName);
if(!gNfsConnection.Connect(url))
return false;
@@ -194,13 +182,13 @@ bool CNFSDirectory::Remove(const char* strPath)
bool CNFSDirectory::Exists(const char* strPath)
{
int ret = 0;
- int existFolderLen = 0;
- CSingleLock lock(gNfsConnection);
-
- CURL url(URIUtils::GetParentPath(strPath));
- CStdString folderName(strPath);
- existFolderLen = folderName.length() - URIUtils::GetParentPath(strPath).length();
- folderName = "//" + folderName.Right(existFolderLen);
+
+ CSingleLock lock(gNfsConnection);
+ CStdString folderName(strPath);
+ URIUtils::RemoveSlashAtEnd(folderName);//remove slash at end or URIUtils::GetFileName won't return what we want...
+
+ CURL url(folderName);
+ folderName = "//" + URIUtils::GetFileName(folderName);
if(!gNfsConnection.Connect(url))
return false;
View
1 xbmc/filesystem/NFSDirectory.h
@@ -22,7 +22,6 @@
#include "IDirectory.h"
#include "FileNFS.h"
-#include "MediaSource.h"
namespace XFILE
{

0 comments on commit 1bb1db5

Please sign in to comment.