750b7abcd5
- .claude/CLAUDE.md - .claude/agents/fn-recopilador/SKILL.md - .claude/rules/INDEX.md - .claude/rules/cpp_apps.md - bash/functions/infra/build_cpp_windows.sh - cpp/CMakeLists.txt - cpp/PATTERNS.md - cpp/framework/app_base.cpp - cpp/framework/app_base.h - dev/issues/README.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
|
|
// job_cache_sha256 — addressable cache layout helper.
|
|
//
|
|
// Layout:
|
|
// <root>/<key[0:2]>/<key><suffix>
|
|
//
|
|
// El caller calcula el `key` (tipicamente SHA-256 hex de algun valor
|
|
// canonico — URL, parametros, etc.). Esta funcion no hashea: solo
|
|
// gestiona el path y la I/O.
|
|
//
|
|
// Suffix permite multiples blobs por la misma key (`.html`, `.md`,
|
|
// `.json`). Pasa "" si solo hay un blob.
|
|
|
|
namespace fn::cache_sha256 {
|
|
|
|
// Pure. Devuelve "<root>/<key[0:2]>/<key><suffix>". No toca disco.
|
|
// Si key tiene menos de 2 caracteres, usa la key entera como subdir.
|
|
std::string path_for(const std::string& root,
|
|
const std::string& key,
|
|
const std::string& suffix = "");
|
|
|
|
// Impure. Crea el directorio `<root>/<key[0:2]>/` si no existe.
|
|
// Devuelve true en exito. No falla si ya existe.
|
|
bool ensure_dir(const std::string& root, const std::string& key);
|
|
|
|
// Impure. Lee el archivo en `path_for(root, key, suffix)` entero.
|
|
// Devuelve true si existia y se leyo; false en caso contrario.
|
|
bool read(const std::string& root,
|
|
const std::string& key,
|
|
const std::string& suffix,
|
|
std::string* out);
|
|
|
|
// Impure. Escribe `bytes` en `path_for(root, key, suffix)`. Crea el
|
|
// directorio padre si no existe. Devuelve true en exito.
|
|
bool write(const std::string& root,
|
|
const std::string& key,
|
|
const std::string& suffix,
|
|
const std::string& bytes);
|
|
|
|
// Impure. true si el archivo existe en `path_for(root, key, suffix)`.
|
|
bool exists(const std::string& root,
|
|
const std::string& key,
|
|
const std::string& suffix);
|
|
|
|
} // namespace fn::cache_sha256
|