Skip to content

Commit

Permalink
Async fs checks , cmake boost policy update
Browse files Browse the repository at this point in the history
  • Loading branch information
kuro337 committed Jul 23, 2024
1 parent 906f078 commit b083c08
Show file tree
Hide file tree
Showing 12 changed files with 457 additions and 21 deletions.
2 changes: 1 addition & 1 deletion include/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ inline void process(llvm::StringRef inputPath, llvm::StringRef outputPath) {
sout << content << '\n';
}

#endif // CLI_H
#endif // CLI_H
35 changes: 19 additions & 16 deletions include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,25 @@ namespace ISOLanguage {
} // namespace ISOLanguage

namespace Ansi {
static constexpr auto BOLD = "\x1b[1m";
static constexpr auto ITALIC = "\x1b[3m";
static constexpr auto UNDERLINE = "\x1b[4mT";
static constexpr auto BRIGHT_WHITE = "\x1b[97m";
static constexpr auto LIGHT_GREY = "\x1b[37m";
static constexpr auto GREEN = "\x1b[92m";
static constexpr auto BOLD_WHITE = "\x1b[1m";
static constexpr auto CYAN = "\x1b[96m";
static constexpr auto BLUE = "\x1b[94m";
static constexpr auto GREEN_BOLD = "\x1b[1;32m";
static constexpr auto ERROR = "\x1b[31m";
static constexpr auto SUCCESS_TICK = "\x1b[32m✔\x1b[0m";
static constexpr auto FAILURE_CROSS = "\x1b[31m✖\x1b[0m";
static constexpr auto WARNING = "\x1b[93m";
static constexpr auto WARNING_BOLD = "\x1b[1;33m";
static constexpr auto END = "\x1b[0m";
static constexpr auto BOLD = "\x1b[1m";
static constexpr auto ITALIC = "\x1b[3m";
static constexpr auto UNDERLINE = "\x1b[4mT";
static constexpr auto BRIGHT_WHITE = "\x1b[97m";
static constexpr auto LIGHT_GREY = "\x1b[37m";
static constexpr auto GREEN = "\x1b[92m";
static constexpr auto RGB_GREEN = "\x1b[38;2;0;255;0m";
static constexpr auto SUCCESS_TICK_RGB = "\x1b[38;2;0;255;0m✔\x1b[0m";
static constexpr auto FOLDER_ICON = "\x1b[33m▸\x1b[0m"; // Alternate yellow folder icon
static constexpr auto BOLD_WHITE = "\x1b[1m";
static constexpr auto CYAN = "\x1b[96m";
static constexpr auto BLUE = "\x1b[94m";
static constexpr auto GREEN_BOLD = "\x1b[1;32m";
static constexpr auto ERROR = "\x1b[31m";
static constexpr auto SUCCESS_TICK = "\x1b[32m✔\x1b[0m";
static constexpr auto FAILURE_CROSS = "\x1b[31m✖\x1b[0m";
static constexpr auto WARNING = "\x1b[93m";
static constexpr auto WARNING_BOLD = "\x1b[1;33m";
static constexpr auto END = "\x1b[0m";
static constexpr auto DELIMITER_STAR =
"\x1b[90m******************************************************"
"\x1b[";
Expand Down
2 changes: 2 additions & 0 deletions include/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ auto file_exists(const llvm::Twine &path) -> bool;
/// @return bool
auto is_dir(const llvm::Twine &directoryPath) -> bool;

int path_stat(const llvm::Twine &unknown_path);

/// @brief Write a String to a File using a raw fd stream - failure indicates the Presence of an
/// Error
/// @param filePath
Expand Down
9 changes: 9 additions & 0 deletions include/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <atomic>
#include <condition_variable>
#include <constants.h>
#include <llvm/Support/FormatVariadic.h>
#include <llvm/Support/raw_ostream.h>
#include <mutex>
Expand Down Expand Up @@ -147,4 +148,12 @@ class AsyncLogger {
}
};

inline void log_success(const std::string &msg) {
llvm::outs() << llvm::formatv("{0} {1}\n", Ansi::SUCCESS_TICK_RGB, msg);
}

inline void log_failure(const std::string &msg) {
llvm::outs() << llvm::formatv("{0} {1}\n", Ansi::FAILURE_CROSS, msg);
}

#endif // LOGGER_H
23 changes: 20 additions & 3 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,20 @@ auto Unwrap(llvm::Expected<T> &&expected) -> bool {
llvm::Error err = expected.takeError();
throw std::runtime_error(llvm::toString(std::move(err)));
}
} else if constexpr (std::is_same_v<Tag, StdErr>) {
}
if constexpr (std::is_same_v<Tag, StdErr>) {
if (!expected) {
llvm::Error err = expected.takeError();
llvm::errs() << "Error: " << llvm::toString(std::move(err)) << '\n';
return false;
}
} else if constexpr (std::is_same_v<Tag, NoThrow>) {
}
if constexpr (std::is_same_v<Tag, NoThrow>) {
if (!expected) {
return false;
}
}

return true;
}

Expand Down Expand Up @@ -319,12 +322,26 @@ inline auto getCurrentTimestamp() -> std::string {

using high_res_clock = std::chrono::high_resolution_clock;
using time_point = std::chrono::time_point<high_res_clock>;
using high_res_clock = std::chrono::high_resolution_clock;
using time_point = std::chrono::time_point<high_res_clock>;
using duration = std::chrono::duration<double>;

/// @brief Initialize the Start Time
/// @return time_point
inline auto getStartTime() -> time_point { return high_res_clock::now(); }

/// @brief Get the Time Elapsed from the Start Time in milliseconds, with
/// fractional part
/// @param startTime
/// @return double - Time in milliseconds with fractions
/// @code{.cpp}
/// auto start = getStartTime();
/// double duration = getDuration(start);
/// @endcode
inline auto getDuration(const time_point &startTime) -> double {
auto endTime = high_res_clock::now();
return std::chrono::duration<double>(endTime - startTime).count();
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime);
return elapsed.count() / 1000.0;
}

inline void printDuration(const time_point &startTime, const std::string &msg) {
Expand Down
15 changes: 15 additions & 0 deletions src/fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,21 @@ auto is_dir(const llvm::Twine &directoryPath) -> bool {
return llvm::sys::fs::is_directory(directoryPath);
}

/// @brief -1 NonExistent , 0:File , 1:Dir
/// @param unknown_path
/// @return int
/// @code{.cpp}
/// @endcode
int path_stat(const llvm::Twine &unknown_path) {
if (!llvm::sys::fs::exists(unknown_path)) {
return -1;
}
if (llvm::sys::fs::is_directory(unknown_path)) {
return 1;
};
return 0;
}

/// @brief Get the Err object as a str for llvm::Expected<T>
/// @param err
/// @return std::string
Expand Down
47 changes: 47 additions & 0 deletions src/schema.capnp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@


# Void: Void
# Boolean: Bool
# Integers: Int8, Int16, Int32, Int64
# Unsigned integers: UInt8, UInt16, UInt32, UInt64
# Floating-point: Float32, Float64
# Blobs: Text, Data
# Lists: List(T)

struct Timestamp {
unixtime @0 :Int64;
}

struct UUID {
type @0 :Type = Seven;
low @1 :UInt64;
high @2 :UInt64;

enum Type {
Seven @0;
Four @1;
}
}

interface Image {
exists @0 () -> (result : Bool);
toText @1 () -> (text : Data);
toHash @2 () -> (result : Data);
}

struct KImage {
id @0 :UUID;
uri @1 :Text;
size @3 :UInt64;
hash @4 :Data;
text @5 :Text;
fuzzhash @6 :Text;
}

# Image
# - id
# - uri
# - hash
# - text
# - format
# - names
46 changes: 46 additions & 0 deletions src/serializer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@


class Serializer {
virtual void serialize() const = 0;
virtual void deserialize() const = 0;
};

class ImageSerializer: Serializer {
void serialize() const override {}

void deserialize() const override {}
};

#include <iostream>

auto main(int argc, char **argv) -> int {
std::cout << "101010" << std::endl;

auto imgs = new ImageSerializer();

return 0;
}

/*
@0xbf5147cbbecf40c1;
struct Image {
id @0 :Int32;
filename @1 :Text;
data @2 :Data;
}
struct TextFile {
id @0 :Int32;
filename @1 :Text;
content @2 :Text;
}
struct DataCollection {
images @0 :List(Image);
texts @1 :List(TextFile);
}
*/
1 change: 1 addition & 0 deletions tests/Testing/Temporary/CTestCostData.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
3 changes: 3 additions & 0 deletions tests/Testing/Temporary/LastTest.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Start testing: Jul 23 03:26 EDT
----------------------------------------------------------
End testing: Jul 23 03:26 EDT
2 changes: 1 addition & 1 deletion tests/similarity_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ TEST(SimilaritySuite, ImageSHA256Unequal) {
auto sha_b = computeSHA256(unequal);

EXPECT_NE(sha_a, sha_b);
}
}
Loading

0 comments on commit b083c08

Please sign in to comment.