68 , m_directory(directory)
73 info() <<
"FileHashDatabase: nb_write_cache=" << m_nb_write_cache
74 <<
" nb_write=" << m_nb_write <<
" nb_read=" << m_nb_read;
79 void writeValues(
const HashDatabaseWriteArgs& args, HashDatabaseWriteResult& xresult)
override
81 Span<const std::byte> bytes = args.values();
82 String hash_value = args.hashValue();
83 xresult.setHashValueAsString(hash_value);
84 DirFileInfo dirfile_info = _getDirFileInfo(hash_value);
85 String base_name = dirfile_info.directory;
86 String full_filename = dirfile_info.full_filename;
90 platform::recursiveCreateDirectory(base_name);
95 std::ifstream ifile(full_filename.localstr());
104 String full_filename = dirfile_info.full_filename;
105 ofstream ofile(full_filename.localstr());
110 ARCANE_FATAL(
"Can not write hash for filename '{0}'", full_filename);
114 void readValues(
const HashDatabaseReadArgs& args)
override
116 const String& hash_value = args.hashValueAsString();
117 Span<std::byte> bytes = args.values();
119 DirFileInfo dirfile_info = _getDirFileInfo(hash_value);
121 String full_filename = dirfile_info.full_filename;
122 std::ifstream ifile(full_filename.localstr());
132 DirFileInfo _getDirFileInfo(
const String& hash_value)
134 char name1 = hash_value.bytes()[0];
135 char name2 = hash_value.bytes()[1];
136 char name3 = hash_value.bytes()[2];
137 StringBuilder base_name_builder = m_directory;
138 base_name_builder +=
'/';
139 base_name_builder += name1;
140 base_name_builder +=
'/';
141 base_name_builder += name2;
142 base_name_builder += name3;
143 String base_name = base_name_builder.toString();
144 String full_filename = String::format(
"{0}/{1}", base_name, hash_value);
145 return DirFileInfo{ base_name, hash_value, full_filename };
151 Int64 m_nb_write_cache = 0;
152 Int64 m_nb_write = 0;