Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <stdio.h>
#include <string>
 
#include "core/common/path_string.h"
 
namespace onnxruntime {
namespace test {
 
// Creates a platform-specific shared library file name from a base library name.
// E.g., "onnxruntime" -> "libonnxruntime.so".
PathString GetSharedLibraryFileName(const PathString& base_library_name);
 
void CreateTestFile(FILE*& out, std::basic_string<ORTCHAR_T>& filename_template);
void CreateTestFile(int& out, std::basic_string<ORTCHAR_T>& filename_template);
void DeleteFileFromDisk(const ORTCHAR_T* path);
 
class ScopedFileDeleter {
 public:
  ScopedFileDeleter() = default;
  ScopedFileDeleter(const PathString& path) : path_{path} {}
  ScopedFileDeleter(ScopedFileDeleter&& other) noexcept { *this = std::move(other); }
  ScopedFileDeleter& operator=(ScopedFileDeleter&& other) noexcept {
    CleanUp();
    path_ = std::move(other.path_);
    other.path_.clear();
    return *this;
  }
  ~ScopedFileDeleter() { CleanUp(); }
 
 private:
  ORT_DISALLOW_COPY_AND_ASSIGNMENT(ScopedFileDeleter);
 
  void CleanUp() {
    if (!path_.empty()) {
      std::remove(ToUTF8String(path_).c_str());
      path_.clear();
    }
  }
 
  PathString path_;
};
 
}  // namespace test
}  // namespace onnxruntime