forked from AmbaPant/mantid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FileResource.h
35 lines (30 loc) · 1.07 KB
/
FileResource.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
/** RAII: Gives a clean file destination and removes the file when
* handle is out of scope. Must be stack allocated.
*
* @author Takudzwa Makoni, RAL (UKRI), ISIS
* @date 06/08/2019
*/
#pragma once
#include <boost/filesystem.hpp>
#include <iostream>
#include <string>
class FileResource {
public:
FileResource(const std::string &fileName, bool debugMode = false);
void setDebugMode(bool mode);
std::string fullPath() const;
~FileResource();
private:
bool m_debugMode;
boost::filesystem::path m_full_path; // full path to file
// prevent heap allocation for ScopedFileHandle
protected:
static void *operator new(std::size_t); // prevent heap allocation of scalar.
static void *operator new[](std::size_t); // prevent heap allocation of array.
};