 
 #c
 rs_result applyPatch(int deltaFd, char* inputPath, char* outputPath) {
-    FILE*      deltaFile, inputFile, outputFile;
+    FILE*      deltaFile;
+    FILE*      inputFile;
+    FILE*      outputFile;
     rs_stats_t stats;
     rs_result  result;
 
-    inputFile  = rs_file_open(inputPath, "rb");
+    inputFile  = fopen(inputPath, "rb");
     deltaFile  = fdopen(deltaFd, "rb");
-    outputFile = rs_file_open(outputPath, "wb");
+    outputFile = fopen(outputPath, "wb");
 
     result = rs_patch_file(inputFile, deltaFile, outputFile, &stats);
 

}
#endc


-- -- | Loading signatures
-- -- the c-function is:
-- -- rs_result rs_loadsig_file(FILE *, rs_signature_t **, rs_stats_t *);
-- {#fun unsafe rs_loadsig_file as cRSLoadSigFile
--       { id      `Ptr CFile'
--       , alloca- `SignaturePtr' peek*
--       , alloca- `StatsPtr'
--       } -> `Result' cIntToEnum
--  #}

--------------------------------------------------------------------------------
-- | Delta


cGenDelta :: Handle -> FilePath -> Handle -> IO (Handle, Result)
cGenDelta sigHandle p deltaHandle = undefined



#c
// generate a delta, based on the implementation of rdiff
rs_result genDelta(int sigFd, char* filePath, int deltaFd) {
    FILE*           sigFile;
    FILE*           f;
    FILE*           deltaFile;
    rs_result       result;
    rs_signature_t* sumset;
    rs_stats_t      stats;

    sigFile   = fdopen(sigFd, "rb");
    f         = fopen(filePath, "rb");
    deltaFile = fdopen(deltaFd, "wb");

    result = rs_loadsig_file(sigFile, &sumset, &stats);
