@@ -252,7 +252,7 @@ class KvsValue final{
252252 * - `snapshot_max_count`: Retrieves the maximum number of snapshots allowed.
253253 * - `snapshot_restore`: Restores the KVS from a specified snapshot.
254254 * - `get_kvs_filename`: Retrieves the filename associated with a snapshot.
255- * - `get_kvs_hash_filename `: Retrieves the hash filename associated with a snapshot.
255+ * - `get_hash_filename `: Retrieves the hash filename associated with a snapshot.
256256 *
257257 * Private Members:
258258 * - `kvs_mutex`: A mutex for ensuring thread safety.
@@ -324,7 +324,7 @@ class Kvs final {
324324 * - OpenNeedKvs::Required: The KVS must already exist.
325325 * - OpenNeedKvs::Optional: An empty KVS will be used if no KVS exists.
326326 * @param dir The directory path where the KVS files are located. It is passed as an rvalue reference to avoid unnecessary copying.
327- * Important: It needs to end with "/" to be a valid directory path .
327+ * Use "" or "." for the current directory.
328328 * @return A Result object containing either:
329329 * - A Kvs object if the operation is successful.
330330 * - An ErrorCode if an error occurs during the operation.
@@ -478,9 +478,11 @@ class Kvs final {
478478 /* *
479479 * @brief Retrieves the number of snapshots currently stored in the key-value store.
480480 *
481- * @return The total count of snapshots as a size_t value.
481+ * @return A score::Result object that indicates the success or failure of the operation.
482+ * - On success: The total count of snapshots as a size_t value.
483+ * - On failure: Returns an ErrorCode describing the error.
482484 */
483- size_t snapshot_count () const ;
485+ score::Result< size_t > snapshot_count () const ;
484486
485487
486488 /* *
@@ -513,9 +515,11 @@ class Kvs final {
513515 * @brief Retrieves the filename associated with a given snapshot ID in the key-value store.
514516 *
515517 * @param snapshot_id The identifier of the snapshot for which the filename is to be retrieved.
516- * @return A String with the filename associated with the snapshot ID.
518+ * @return score::ResultBlank
519+ * - On success: A score::filesystem::Path with the filename (path) associated with the snapshot ID.
520+ * - On failure: An error code describing the reason for the failure.
517521 */
518- std::string get_kvs_filename (const SnapshotId& snapshot_id) const ;
522+ score::Result<score::filesystem::Path> get_kvs_filename (const SnapshotId& snapshot_id) const ;
519523
520524
521525 /* *
@@ -526,9 +530,11 @@ class Kvs final {
526530 * store metadata or integrity information for the snapshot.
527531 *
528532 * @param snapshot_id The identifier of the snapshot for which the hash filename is requested.
529- * @return A String with the filename of the hash file associated with the snapshot ID.
533+ * @return score::ResultBlank
534+ * - On success: A score::filesystem::Path with the filename (path) of the hash file associated with the snapshot ID.
535+ * - On failure: An error code describing the reason for the failure.
530536 */
531- std::string get_kvs_hash_filename (const SnapshotId& snapshot_id) const ;
537+ score::Result<score::filesystem::Path> get_hash_filename (const SnapshotId& snapshot_id) const ;
532538
533539 private:
534540 /* Private constructor to prevent direct instantiation */
@@ -545,17 +551,20 @@ class Kvs final {
545551 std::unordered_map<std::string, KvsValue> default_values;
546552
547553 /* Filename prefix */
548- std::string filename_prefix;
554+ score::filesystem::Path filename_prefix;
549555
550556 /* Flush on exit flag for written Keys */
551557 std::atomic<bool > flush_on_exit;
552558
559+ /* Filesystem handling */
560+ std::unique_ptr<score::filesystem::Filesystem> filesystem;
561+
553562 /* Json handling */
554563 std::unique_ptr<score::json::IJsonParser> parser;
555564 std::unique_ptr<score::json::IJsonWriter> writer;
556565
557566 score::Result<std::unordered_map<std::string, KvsValue>> parse_json_data (const std::string& data);
558- score::Result<std::unordered_map<std::string, KvsValue>> open_json (const std::string & prefix, OpenJsonNeedFile need_file);
567+ score::Result<std::unordered_map<std::string, KvsValue>> open_json (const score::filesystem::Path & prefix, OpenJsonNeedFile need_file);
559568 score::ResultBlank write_json_data (const std::string& buf);
560569};
561570
@@ -589,9 +598,8 @@ class KvsBuilder final {
589598 /* *
590599 * @brief Specify the directory where KVS files are stored.
591600 * @param dir The directory path as a string.
592- * Important: The directory path must end with a '/' to be valid.
593- * Use "./" for the current directory.
594- *
601+ * Use "" or "." for the current directory.
602+ *
595603 * @return Reference to this builder (for chaining).
596604 */
597605 KvsBuilder& dir (std::string&& dir_path);
@@ -603,7 +611,7 @@ class KvsBuilder final {
603611 *
604612 * @return A score::Result<Kvs> containing the opened store or an ErrorCode.
605613 */
606- score::Result<Kvs> build () const ;
614+ score::Result<Kvs> build ();
607615
608616private:
609617 InstanceId instance_id; // /< ID of the KVS instance
0 commit comments