mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 18:08:53 +00:00
971bee4441
fbshipit-source-id: 8ffef5e6a393ac67ce56dcb74845402e43d964a0
52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under both the Apache 2.0 license (found in the
|
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
* in the COPYING file in the root directory of this source tree).
|
|
* You may select, at your option, one of the above-listed licenses.
|
|
*/
|
|
|
|
#include <osquery/filesystem/filesystem.h>
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
namespace osquery {
|
|
|
|
namespace fs = boost::filesystem;
|
|
|
|
fs::path createMockFileStructure() {
|
|
const auto root_dir =
|
|
fs::temp_directory_path() /
|
|
fs::unique_path("osquery.tests.%%%%.%%%%");
|
|
fs::create_directories(root_dir / "toplevel/");
|
|
fs::create_directories(root_dir / "toplevel/secondlevel1");
|
|
fs::create_directories(root_dir / "toplevel/secondlevel2");
|
|
fs::create_directories(root_dir / "toplevel/secondlevel3");
|
|
fs::create_directories(root_dir / "toplevel/secondlevel3/thirdlevel1");
|
|
fs::create_directories(root_dir / "deep11/deep2/deep3/");
|
|
fs::create_directories(root_dir / "deep1/deep2/");
|
|
writeTextFile(root_dir / "root.txt", "root");
|
|
writeTextFile(root_dir / "door.txt", "toor", 0550);
|
|
writeTextFile(root_dir / "roto.txt", "roto");
|
|
writeTextFile(root_dir / "deep1/level1.txt", "l1");
|
|
writeTextFile(root_dir / "deep11/not_bash", "l1");
|
|
writeTextFile(root_dir / "deep1/deep2/level2.txt", "l2");
|
|
|
|
writeTextFile(root_dir / "deep11/level1.txt", "l1");
|
|
writeTextFile(root_dir / "deep11/deep2/level2.txt", "l2");
|
|
writeTextFile(root_dir / "deep11/deep2/deep3/level3.txt", "l3");
|
|
|
|
#ifdef WIN32
|
|
writeTextFile(root_dir / "root2.txt", "l1");
|
|
#else
|
|
boost::system::error_code ec;
|
|
fs::create_symlink(
|
|
root_dir / "root.txt", root_dir / "root2.txt", ec);
|
|
#endif
|
|
return root_dir;
|
|
}
|
|
|
|
} // namespace osquery
|