1 /*
2  *  Copyright (C) 2014-2018 Team Kodi
3  *  This file is part of Kodi - https://kodi.tv
4  *
5  *  SPDX-License-Identifier: GPL-2.0-or-later
6  *  See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "filesystem/IFile.h"
12 
13 #include <string>
14 
15 typedef void* HANDLE; // forward declaration
16 
17 namespace XFILE
18 {
19   class CWin32File : public IFile
20   {
21   public:
22     CWin32File();
23     virtual ~CWin32File();
24 
25     virtual bool Open(const CURL& url);
26     virtual bool OpenForWrite(const CURL& url, bool bOverWrite = false);
27     virtual void Close();
28 
29     virtual ssize_t Read(void* lpBuf, size_t uiBufSize);
30     virtual ssize_t Write(const void* lpBuf, size_t uiBufSize);
31     virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET);
32     virtual int Truncate(int64_t toSize);
33     virtual int64_t GetPosition();
34     virtual int64_t GetLength();
35     virtual void Flush();
36 
37     virtual bool Delete(const CURL& url);
38     virtual bool Rename(const CURL& urlCurrentName, const CURL& urlNewName);
39     virtual bool SetHidden(const CURL& url, bool hidden);
40     virtual bool Exists(const CURL& url);
41     virtual int Stat(const CURL& url, struct __stat64* statData);
42     virtual int Stat(struct __stat64* statData);
43 
44   protected:
45     explicit CWin32File(bool asSmbFile);
46     HANDLE  m_hFile;
47     int64_t m_filePos;
48     bool    m_allowWrite;
49     // file path and name in win32 long form "\\?\D:\path\to\file.ext"
50     std::wstring m_filepathnameW;
51     const bool m_smbFile; // true for SMB file, false for local file
52     unsigned long m_lastSMBFileErr; // used for SMB file operations
53   };
54 
55 }
56