💾 Archived View for gmi.noulin.net › gitRepositories › blockFile › file › main.c.gmi captured on 2023-01-29 at 13:21:06. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

blockFile

Log

Files

Refs

LICENSE

main.c (2074B)

     1 #! /usr/bin/env sheepy
     2 
     3 #include "libsheepyObject.h"
     4 #include "blockFile.h"
     5 
     6 int argc; char **argv;
     7 
     8 // TEST
     9 
    10 bool loadFunc(void *c, u64 b, bufBlockFilet data) {
    11   cast(char*, s, data.data);
    12   logVarG(b);
    13   logVarG(s);
    14   logVarG(data.len);
    15   return true;
    16 }
    17 
    18 // END TEST
    19 
    20 int main(int ARGC, char** ARGV) {
    21 
    22   argc = ARGC; argv = ARGV;
    23 
    24   initLibsheepy(argv[0]);
    25 
    26   char *filename = "file.db";
    27 
    28   /* createBlockFile(bf); */
    29   /* bf.f->deleteF(filename); */
    30   /* freeO(&bf); */
    31 
    32   blockFilet *file = allocBlockFile("file.db");
    33 
    34   loadBFO(file, NULL, loadFunc);
    35   XSUCCESS;
    36 
    37   // add data to a block: addBlock(file, void*, length): u64 block
    38   // add data in many blocks: addData(file, void*, length): u64[], end with 0
    39   // save index of first block in first u64 of the block
    40   // save next block index in second u64 of the block, when next block index is 0, the chain is finished
    41   // use free block first, when there are no free blocks
    42   // update freeF
    43   logVarG(addBFO(file, "qweqwe", 6));
    44   char *s1 = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
    45   char *s2 = "222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 cfp command printing current path in front of given parameters searchReplace command searches strings in files and replaces them with given searchReplace command searches strings in files and replaces them with";
    46   addBFO(file, s1, strlen(s1));
    47   logVarG(removeBFO(file, 1));
    48   logVarG(addBFO(file, s2, strlen(s2)));
    49 
    50   // get block
    51 
    52   // remove data: remove(file, block): bool
    53   // read block header
    54   // find first block
    55   // add blocks to freeF
    56 
    57   // load: load(file, callback)
    58   // read block 1, find first block
    59   // add read blocks to a list
    60   // find next chain of blocks
    61   // > recreate index, or save the index
    62 
    63   // delete block file: delete(file)
    64   //delete(file);
    65 
    66   // close: close(file)
    67   closeBFO(file);
    68 
    69   // delete file: deleteF(filename)
    70   //deleteF(filename);
    71 }