-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimage_burner_impl.h
69 lines (53 loc) · 2.04 KB
/
image_burner_impl.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IMAGE_BURNER_IMAGE_BURNER_IMPL_H_
#define IMAGE_BURNER_IMAGE_BURNER_IMPL_H_
#include <string>
#include "image-burner/image_burner_utils_interfaces.h"
#include <gtest/gtest_prod.h>
namespace imageburn {
enum ErrorCode {
IMAGEBURN_OK = 0,
IMAGEBURN_ERROR_NULL_SOURCE_PATH,
IMAGEBURN_ERROR_NULL_TARGET_PATH,
IMAGEBURN_ERROR_TARGET_PATH_ON_ROOT,
IMAGEBURN_ERROR_INVALID_TARGET_PATH,
IMAGEBURN_ERROR_CANNOT_OPEN_SOURCE,
IMAGEBURN_ERROR_CANNOT_OPEN_TARGET,
IMAGEBURN_ERROR_CANNOT_CLOSE_SOURCE,
IMAGEBURN_ERROR_CANNOT_CLOSE_TARGET,
IMAGEBURN_ERROR_FAILED_READING_SOURCE,
IMAGEBURN_ERROR_FAILED_WRITING_TO_TARGET,
IMAGEBURN_ERROR_FAILED_SYNCING_TARGET,
IMAGEBURN_ERROR_BURNER_NOT_INITIALIZED,
IMAGEBURN_ERROR_SOURCE_REAL_PATH_NOT_DETERMINED,
IMAGEBURN_ERROR_SOURCE_PATH_NOT_ALLOWED,
};
class BurnerImpl {
public:
BurnerImpl(FileSystemWriter* writer,
FileSystemReader* reader,
SignalSender* signal_sender,
PathGetter* path_getter);
// Returns error code (error code for success == 0)
ErrorCode BurnImage(const char* from_path, const char* to_path);
void InitSignalSender(SignalSender* signal_sender);
// We use this primary for testing.
void SetDataBlockSize(int value) { data_block_size_ = value; }
private:
FRIEND_TEST(ImageBurnerImplTest, IsSourcePathAllowed);
bool IsSourcePathAllowed(const std::string& path) const;
bool ValidateTargetPath(const char* path, ErrorCode* error);
bool ValidateSourcePath(const char* path,
std::string* resolved_path,
ErrorCode* error);
bool DoBurn(const char* from_path, const char* to_path, ErrorCode* error);
FileSystemWriter* writer_;
FileSystemReader* reader_;
SignalSender* signal_sender_;
PathGetter* path_getter_;
int data_block_size_;
};
} // namespace imageburn
#endif // IMAGE_BURNER_IMAGE_BURNER_IMPL_H_