<commit_before>
##
fs = require 'fs'

##
path = require 'path'

##
zlib = require 'zlib'


##
##
##
module.exports = files =
    
    ##
    fs: fs

    ##
    path: path
    
    ##
    ##
    appdir: (args...)->
        
        normpath args


    ##
    ##
    mkdir: (dir)->
        parts = normpath(dir).split('/'); 
        
        temp = '/'
        while parts.length > 0
            if !fs.existsSync( temp = path.join temp, parts.shift() )
                fs.mkdirSync temp
        
        return dir    
        
    
    ##
    ##
    exists: (name)->
    
        return fs.existsSync normpath name            
    
    
    ##
    ##
    stat: (name)->

        return fs.lstatSync normpath name            
    
    ##
    ##
    is_dir: (name)->
        
        files.stat(normpath name).isDirectory()
    
    ##
    ##
    list: (dir)->
        
        fs.readdirSync normpath(dir)            
    
    
    ##
    ##
    write: (name, data, enc='utf8')->
        
        fs.writeFileSync normpath(name), data, enc
    
    ##
    ##
    read: (name, enc='utf8')->
            
        fs.readFileSync normpath(name), enc
    
    
    ##
    ##
    cp: (srcFile, destFile) ->
        buff = new Buffer BUF_LENGTH = 64*1024
         
        fdr = fs.openSync srcFile, 'r' 
        fdw = fs.openSync destFile, 'w'
         
        bytesRead = 1
        pos = 0
        while bytesRead > 0
          bytesRead = fs.readSync fdr, buff, 0, BUF_LENGTH, pos 
          fs.writeSync fdw,buff,0,bytesRead 
          pos += bytesRead
          
        fs.closeSync fdr 
        fs.closeSync fdw 
        
    
    ##
    ##
    mv: (old_name, new_name...)->
        <commit_msg>add async option to most functions<commit_after>
##
fs = require 'fs'

##
path = require 'path'

##
zlib = require 'zlib'


##
##
##
module.exports = files =
    
    ##
    fs: fs

    ##
    path: path
    
    ##
    ##
    appdir: (args...)->
        
        normpath args


    ##
    ##
    mkdir: (dir)->
        parts = normpath(dir).split('/'); 
        
        temp = '/'
        while parts.length > 0
            if !fs.existsSync( temp = path.join temp, parts.shift() )
                fs.mkdirSync temp
        
        return dir    
        
    
    ##
    ##
    exists: (name, fn)->
        if fn
            fs.exists normpath(name), fn
        
        else fs.existsSync normpath name            
    
    
    ##
    ##
    stat: (name, fn)->
        if fn
            fs.lstat normpath(name), fn
        
        else fs.lstatSync normpath name            
    
    ##
    ##
    is_dir: (name, fn)->
        if fn
            files.stat name, (err, stat)->
                fn err, stat?.isDirectory()
                
        else files.stat(name).isDirectory()
    
    ##
    ##
    list: (dir, fn)->
        if fn
            fs.readdir normpath(dir), fn
            
        else fs.readdirSync normpath(dir)            
    
    
    ##
    ##
    write: (name, data, enc='utf8', fn)->
        if fn
            fs.writeFile normpath(name), data, enc, fn
            
        else fs.writeFileSync normpath(name), data, enc
    
    ##
    ##
    read: (name, enc='utf8', fn)->
        if fn
            fs.readFileSync normpath(name), enc, fn
            
        else fs.readFileSync normpath(name), enc
    
    
    ##
    ##
    cp: (srcFile, destFile) ->
        buff = new Buffer BUF_LENGTH = 64*1024
         
        fdr = fs.openSync srcFile, 'r' 
        fdw = fs.openSync destFile, 'w'
         
        bytesRead = 1
        pos = 0
        while bytesRead > 0
          bytesRead = fs.readSync fdr, buff, 0, BUF_LENGTH, pos 
          fs.writeSync fdw,buff,0,bytesRead 
          pos += bytesRead
          
        fs.closeSync fdr 
        fs.closeSync fdw 
        
    
    ##
    ##
    mv: (old_name, new_name...)->
        
{'fraction_non_alphanumeric': 0.12267561983471074, 'fraction_numerical': 0.007231404958677686, 'mean_word_length': 1.1374172185430464, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2866587', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1219, 'n_words': 277}