<commit_before>(function() {
    'use strict';
    
    var copymitter  = require('copymitter'),
        mellow      = require('mellow');
    
    module.exports = function(socket, options) {
        if (!options)
            options = {};
        
        listen(socket, options);
    };
    
    function getRoot(root) {
        var value;
        
        if (typeof root === 'function')
            value = root();
        else
            value = root;
        
        return value;
    }
    
    function listen(socket, options) {
        var prefix  = options.prefix || 'spero',
            root    = options.root   || '/';
        
        socket.of(prefix)
            .on('connection', function(socket) {
                socket.on('copy', function(from, to, files) {
                    var value   = getRoot(root);
                    
                    from        = mellow.pathToWin(from, value);
                    to          = mellow.pathToWin(to, value);
                    copy(socket, from, to, files);
                });
                
                socket.on('error', function(error) {
                    console.error('spero', error);
                });
            })
            .on('error', function(error) {
                console.error(error);
            });
    }
    
    function copy(socket, from, to, files) {
        var cp = copymitter(from, to, files);
        
        socket.on('pause', cp.pause);
        
        cp.on('file', function(name) {
            socket.emit('file', name);
        });
        
        cp.on('progress', function(percent) {
            socket.emit('progress', percent); 
        });
        
        cp.on('error', function(error, name) {<commit_msg>feature(spero) add check of root win32<commit_after>(function() {
    'use strict';
    
    var copymitter  = require('copymitter'),
        mellow      = require('mellow');
    
    module.exports = function(socket, options) {
        if (!options)
            options = {};
        
        listen(socket, options);
    };
    
    function getRoot(root) {
        var value;
        
        if (typeof root === 'function')
            value = root();
        else
            value = root;
        
        return value;
    }
    
    function isRootWin32(path, root) {
        var isRoot      = path === '/',
            isWin32     = process.platform === 'win32',
            isConfig    = root === '/';
        
        return isWin32 && isRoot && isConfig;
    }
    
    function getWin32RootMsg() {
        var message  = 'Could not copy from/to root on windows!',
            error       = Error(message);
        
        return error;
    }
    
    function listen(socket, options) {
        var prefix  = options.prefix || 'spero',
            root    = options.root   || '/';
        
        socket.of(prefix)
            .on('connection', function(socket) {
                socket.on('copy', function(from, to, files) {
                    var value   = getRoot(root);
                    
                    from        = mellow.pathToWin(from, value);
                    to          = mellow.pathToWin(to, value);
                    
                    
                    if ([from, to].some(function(item) {
                        return isRootWin32(item, root);
                    }))
                        socket.emit('err', getWin32RootMsg());
                    else
                        copy(socket, from, to, files);
                });
                
                socket.on('error', function(error) {
                    console.error('spero', error);
                });
            })
            .on('error', function(error) {
                console.error(error);
            });
    }
    
    function copy(socket, from, to, files) {
        var cp = copymitter(from, to, files);
        
        socket.on('pause', cp.pause);
        
        cp.on('file', function(name) {
            socket.emit('file', name);
        });
        
        cp.on('progress', function(percent) {
            socket.emit('progress', percent); 
        });
        
        cp.on('error', function(error, name) {
{'fraction_non_alphanumeric': 0.12631578947368421, 'fraction_numerical': 0.003827751196172249, 'mean_word_length': 1.1912997903563942, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '166824', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1077, 'n_words': 224}