All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
iOSFileIO.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "IFileIO.h"
6 #include <sys/stat.h>
7 #include "Types.h"
8 #include <string>
9 #include <vector>
10 #import <Foundation/Foundation.h>
11 
12 namespace Eegeo
13 {
14  namespace iOS
15  {
17  {
18  public:
19  iOSFileIO(const std::string& assetPathPrefix = std::string(""));
20 
21  iOSFileIO(const std::vector<std::string>& bundleIdentifiers,
22  const std::string& assetPathPrefix);
23 
24  virtual ~iOSFileIO();
25  virtual bool GetUrl(const std::string& name, char* fileURL);
26 
27  virtual bool OpenFile(std::fstream& stream, size_t& size, const std::string& name, std::ios_base::openmode mode=std::ifstream::in);
28  virtual bool WriteFile(const Byte* data, size_t size, const std::string& name, std::ios_base::openmode mode=std::ifstream::out);
29  virtual bool DeleteFile(const std::string& name);
30  virtual bool Exists(const std::string& name);
31  virtual bool TryStat(const std::string& name, Helpers::FileStat& out_filestat);
32  virtual std::string GetAppFilePathname(const std::string& filename);
33 
34  private:
35  CFURLRef FindResourceUrlInBundles(CFStringRef resourceName, CFStringRef resourceExtension, CFStringRef subDirectoryName) const;
36 
37  const std::string m_assetPathPrefix;
38 
39  std::vector<CFBundleRef> m_bundles;
40  };
41  }
42 }