Rearrange project files.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include "internal/vase/vase.h"
|
||||
#include "pch.h"
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "buffer/original.h"
|
||||
#include "constants.h"
|
||||
#include "pch.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
struct Shard {
|
||||
enum struct Kind : uint8_t {
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "pch.h"
|
||||
#include "search.h"
|
||||
#include "shard.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
struct Point {
|
||||
uint64_t row;
|
||||
@@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
inline int read_file(const char *path, char **text, uint32_t *len) {
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (!f)
|
||||
return 0;
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
long size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
if (size < 0 || size > UINT32_MAX) {
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*len = (uint32_t)size;
|
||||
|
||||
*text = (char *)malloc(*len + 1);
|
||||
if (!*text) {
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t read = fread(*text, 1, *len, f);
|
||||
fclose(f);
|
||||
|
||||
if (read != *len) {
|
||||
free(*text);
|
||||
*text = nullptr;
|
||||
*len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "vase/buffer/append.h"
|
||||
#include "internal/vase/buffer/append.h"
|
||||
|
||||
AppendBuffer::AppendBuffer(std::filesystem::path base_dir) {
|
||||
base_dir /= "tapp.XXXXXX";
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "vase/buffer/original.h"
|
||||
#include "io/file.h"
|
||||
#include "internal/vase/buffer/original.h"
|
||||
|
||||
OriginalBuffer::OriginalBuffer(std::filesystem::path base_dir) {
|
||||
if (!std::filesystem::exists(base_dir) || !std::filesystem::is_directory(base_dir))
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "vase/iterators/line.h"
|
||||
#include "internal/vase/iterators/line.h"
|
||||
|
||||
LineIterator::LineIterator(Shard *root, uint64_t line_num, Direction dir)
|
||||
: it(root, dir), dir(dir) {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "vase/iterators/petal.h"
|
||||
#include "internal/vase/iterators/petal.h"
|
||||
|
||||
PetalIterator::PetalIterator(Shard *r, Direction dir)
|
||||
: dir(dir), root(r) {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "vase/vase.h"
|
||||
#include "internal/vase/vase.h"
|
||||
|
||||
std::vector<ReplacePart> Vase::parse_replace(std::string_view s) {
|
||||
std::vector<ReplacePart> parts;
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "vase/iterators/petal.h"
|
||||
#include "vase/vase.h"
|
||||
#include "internal/vase/iterators/petal.h"
|
||||
#include "internal/vase/vase.h"
|
||||
|
||||
std::vector<RegexMatch> Vase::_regex_search(
|
||||
std::string_view pattern, Range range, std::string_view options
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "vase/shard.h"
|
||||
#include "internal/vase/shard.h"
|
||||
|
||||
void Shard::retain(Shard *n) {
|
||||
if (n)
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "vase/vase.h"
|
||||
#include "utils/utils.h"
|
||||
#include "vase/iterators/line.h"
|
||||
#include "vase/iterators/petal.h"
|
||||
#include "internal/vase/vase.h"
|
||||
#include "internal/vase/iterators/line.h"
|
||||
#include "internal/vase/iterators/petal.h"
|
||||
|
||||
Vase::Vase(std::filesystem::path path, std::filesystem::path swapdir)
|
||||
: path(path), swapdir(swapdir) {
|
||||
+1
-17
@@ -1,23 +1,7 @@
|
||||
#include "cli/cli.h"
|
||||
#include "pch.h"
|
||||
#include "vase/iterators/line.h"
|
||||
#include "vase/vase.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 2)
|
||||
throw std::runtime_error("Please give filename.");
|
||||
|
||||
Vase vase = Vase(argv[1], "/tmp");
|
||||
|
||||
Point p = {UINT64_MAX, UINT64_MAX};
|
||||
vase.insert(&p, 'c');
|
||||
|
||||
printf("%s\n\n", vase.to_string().c_str());
|
||||
|
||||
printf("%lu bytes\n"
|
||||
"%lu lines\n"
|
||||
"\n",
|
||||
vase.length(),
|
||||
vase.root->lines);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user