4 * Copyright (C) 2005-2013 Team XBMC
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
23 // FileSmb.h: interface for the CSmbFile class.
27 //////////////////////////////////////////////////////////////////////
32 #include "threads/CriticalSection.h"
34 #define NT_STATUS_CONNECTION_REFUSED long(0xC0000000 | 0x0236)
35 #define NT_STATUS_INVALID_HANDLE long(0xC0000000 | 0x0008)
36 #define NT_STATUS_ACCESS_DENIED long(0xC0000000 | 0x0022)
37 #define NT_STATUS_OBJECT_NAME_NOT_FOUND long(0xC0000000 | 0x0034)
38 #define NT_STATUS_INVALID_COMPUTER_NAME long(0xC0000000 | 0x0122)
41 typedef _SMBCCTX SMBCCTX;
43 class CSMB : public CCriticalSection
51 void PurgeEx(const CURL& url);
53 void SetActivityTime();
54 void AddActiveConnection();
55 void AddIdleConnection();
56 CStdString URLEncode(const CStdString &value);
57 CStdString URLEncode(const CURL &url);
59 DWORD ConvertUnixToNT(int error);
62 CStdString m_strLastHost;
63 CStdString m_strLastShare;
65 int m_OpenConnections;
66 unsigned int m_IdleTimeout;
74 class CSmbFile : public IFile
78 int OpenFile(const CURL &url, CStdString& strAuth);
81 virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET);
82 virtual unsigned int Read(void* lpBuf, int64_t uiBufSize);
83 virtual bool Open(const CURL& url);
84 virtual bool Exists(const CURL& url);
85 virtual int Stat(const CURL& url, struct __stat64* buffer);
86 virtual int Stat(struct __stat64* buffer);
87 virtual int Truncate(int64_t size);
88 virtual int64_t GetLength();
89 virtual int64_t GetPosition();
90 virtual int Write(const void* lpBuf, int64_t uiBufSize);
92 virtual bool OpenForWrite(const CURL& url, bool bOverWrite = false);
93 virtual bool Delete(const CURL& url);
94 virtual bool Rename(const CURL& url, const CURL& urlnew);
95 virtual int GetChunkSize() {return 1;}
99 bool IsValidFile(const CStdString& strFileName);
100 CStdString GetAuthenticatedPath(const CURL &url);