mirror of
https://github.com/xevidos/codiad.git
synced 2025-01-03 11:42:12 +01:00
Removed lingering collaborative files and references, removed developer log from site title.
This commit is contained in:
parent
dd9e140118
commit
79f02158fd
4 changed files with 0 additions and 512 deletions
|
@ -37,8 +37,6 @@ if( defined( "SITE_NAME" ) && ! ( SITE_NAME === "" || SITE_NAME === null ) ) {
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title><?php echo htmlentities( $site_name ); ?></title>
|
<title><?php echo htmlentities( $site_name ); ?></title>
|
||||||
<script>console.log( '<?php echo $site_name;?>' )</script>
|
|
||||||
<script src="./js/socket.io.js"></script>
|
|
||||||
<?php
|
<?php
|
||||||
// Load System CSS Files
|
// Load System CSS Files
|
||||||
$stylesheets = array("jquery.toastmessage.css","reset.css","fonts.css","screen.css");
|
$stylesheets = array("jquery.toastmessage.css","reset.css","fonts.css","screen.css");
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,297 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Codiad (codiad.com) & Isaac Brown (telaaedifex.com),
|
|
||||||
* distributed as-is and without warranty under the MIT License. See
|
|
||||||
* [root]/license.txt for more. This information must remain intact.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function (global, $) {
|
|
||||||
|
|
||||||
var codiad = global.codiad,
|
|
||||||
scripts = document.getElementsByTagName('script'),
|
|
||||||
path = scripts[scripts.length-1].src.split('?')[0],
|
|
||||||
curpath = path.split( '/' ).slice( 0, -1 ).join( '/ ') + '/';
|
|
||||||
|
|
||||||
var buffer_dumped = false;
|
|
||||||
var collaborator = null;
|
|
||||||
var current_editor = codiad.active.getPath();
|
|
||||||
var cursor = null;
|
|
||||||
var editor = null;
|
|
||||||
var initial = false;
|
|
||||||
var just_cleared_buffer = null;
|
|
||||||
var just_opened = false;
|
|
||||||
var last_applied_change = null;
|
|
||||||
var loaded = false;
|
|
||||||
var loading = true;
|
|
||||||
var session_id = codiad.system.session_id;
|
|
||||||
var site_id = codiad.system.site_id;
|
|
||||||
|
|
||||||
function Collaborator( file_path, session_id ) {
|
|
||||||
|
|
||||||
|
|
||||||
this.collaboration_socket = null
|
|
||||||
let file_id = btoa( current_editor );
|
|
||||||
this.collaboration_socket = io.connect( "https://local.telaaedifex.com:1337", {'forceNew': true, query:'?session=' + session_id + "&file=" + site_id + current_editor} );
|
|
||||||
|
|
||||||
this.collaboration_socket.on( "change", function(delta) {
|
|
||||||
|
|
||||||
if( current_editor !== codiad.active.getPath() || editor === null ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
delta = JSON.parse( delta ) ;
|
|
||||||
last_applied_change = delta ;
|
|
||||||
editor.getSession().getDocument().applyDeltas( [delta] ) ;
|
|
||||||
}.bind() );
|
|
||||||
|
|
||||||
this.collaboration_socket.on( "clear_buffer", function() {
|
|
||||||
just_cleared_buffer = true ;
|
|
||||||
console.log( "setting editor contents" ) ;
|
|
||||||
editor.setValue( "" ) ;
|
|
||||||
}.bind() );
|
|
||||||
|
|
||||||
this.collaboration_socket.on( "recieve_init", function(delta) {
|
|
||||||
|
|
||||||
delta = JSON.parse( delta ) ;
|
|
||||||
|
|
||||||
console.log( 'Recieved dump buffer JSON', delta.message, delta.initial );
|
|
||||||
initial = delta.initial;
|
|
||||||
|
|
||||||
if ( delta.initial === true ) {
|
|
||||||
|
|
||||||
console.log( 'Setting initial content...' );
|
|
||||||
//codiad.editor.setContent( '' );
|
|
||||||
codiad.editor.setContent( delta.content )
|
|
||||||
inital = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(function(){
|
|
||||||
if( cursor !== null ) {
|
|
||||||
console.log( 'Going to position: ' + cursor.row + ", " + cursor.column );
|
|
||||||
editor.gotoLine( cursor.row, cursor.column, true );
|
|
||||||
}
|
|
||||||
}, 256);
|
|
||||||
|
|
||||||
}.bind() );
|
|
||||||
|
|
||||||
this.collaboration_socket.on( "recieve_content", function( ) {
|
|
||||||
|
|
||||||
console.log( 'Someone is joining ...' );
|
|
||||||
console.log( 'Cursor is at ' + cursor.row + ", " + cursor.column );
|
|
||||||
|
|
||||||
// Remove change callback
|
|
||||||
editor.removeEventListener( "change", handle_change );
|
|
||||||
codiad.editor.disableEditing();
|
|
||||||
codiad.editor.setContent( '' );
|
|
||||||
collaborator.dump_buffer()
|
|
||||||
// registering change callback
|
|
||||||
editor.addEventListener( "change", handle_change );
|
|
||||||
}.bind() );
|
|
||||||
|
|
||||||
this.collaboration_socket.on( "unlock", function( ) {
|
|
||||||
|
|
||||||
console.log( 'Unlocking editors and going to ' + cursor.row + ", " + cursor.column );
|
|
||||||
|
|
||||||
codiad.editor.enableEditing();
|
|
||||||
setTimeout(function(){
|
|
||||||
if( cursor !== null ) {
|
|
||||||
console.log( 'Going to position: ' + cursor.row + ", " + cursor.column );
|
|
||||||
editor.gotoLine( cursor.row, cursor.column, true );
|
|
||||||
}
|
|
||||||
}, 256);
|
|
||||||
}.bind() );
|
|
||||||
|
|
||||||
window.collaboration_socket = this.collaboration_socket;
|
|
||||||
}
|
|
||||||
|
|
||||||
Collaborator.prototype.change = function( delta ) {
|
|
||||||
|
|
||||||
this.collaboration_socket.emit( "change", delta );
|
|
||||||
}
|
|
||||||
|
|
||||||
Collaborator.prototype.clear_buffer = function() {
|
|
||||||
this.collaboration_socket.emit( "clear_buffer" );
|
|
||||||
}
|
|
||||||
|
|
||||||
Collaborator.prototype.disconnect = function() {
|
|
||||||
this.collaboration_socket.emit( "disconnect" );
|
|
||||||
}
|
|
||||||
|
|
||||||
Collaborator.prototype.dump_buffer = function() {
|
|
||||||
this.collaboration_socket.emit( "dump_buffer" );
|
|
||||||
}
|
|
||||||
|
|
||||||
Collaborator.prototype.send_init = function( content ) {
|
|
||||||
this.collaboration_socket.emit( "send_init", content );
|
|
||||||
}
|
|
||||||
|
|
||||||
function handle_change( e ) {
|
|
||||||
|
|
||||||
// TODO, we could make things more efficient and not likely to conflict by keeping track of change IDs
|
|
||||||
coords = editor.getCursorPosition();
|
|
||||||
if( coords.row !== 0 && coords.column !== 0 ) {
|
|
||||||
cursor = editor.getCursorPosition();
|
|
||||||
cursor.row = cursor.row + 1
|
|
||||||
console.log( 'Cursor at: ' + cursor.row + ", " + cursor.column );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( last_applied_change!=e && !just_cleared_buffer ) {
|
|
||||||
|
|
||||||
collaborator.change( JSON.stringify(e) );
|
|
||||||
}
|
|
||||||
|
|
||||||
just_cleared_buffer = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function close() {
|
|
||||||
|
|
||||||
if( typeof window.collaboration_socket === 'undefined' ) {
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( window.collaboration_socket !== null ) {
|
|
||||||
|
|
||||||
window.collaboration_socket.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( editor !== null ) {
|
|
||||||
|
|
||||||
editor.removeEventListener( "change", handle_change );
|
|
||||||
}
|
|
||||||
|
|
||||||
editor = null;
|
|
||||||
loaded = false;
|
|
||||||
//current_editor = null;
|
|
||||||
window.collaboration_socket = null;
|
|
||||||
console.log( 'Cleared buffer and closed editor.' );
|
|
||||||
}
|
|
||||||
|
|
||||||
function body_loaded() {
|
|
||||||
|
|
||||||
if( collaborator !== null && editor !== null && initial === false ) {
|
|
||||||
|
|
||||||
if( last_applied_change !== null ) {
|
|
||||||
|
|
||||||
editor.setValue( "" )
|
|
||||||
collaborator.dump_buffer()
|
|
||||||
}
|
|
||||||
//document.getElementsByTagName('textarea')[0].focus() ;
|
|
||||||
last_applied_change = null ;
|
|
||||||
just_cleared_buffer = false ;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
current_editor = codiad.active.getPath();
|
|
||||||
editor = ace.edit( codiad.editor.getActive() );
|
|
||||||
|
|
||||||
if( editor === null ) {
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let content = null;
|
|
||||||
|
|
||||||
collaborator = new Collaborator( session_id );
|
|
||||||
|
|
||||||
//codiad.editor.disableEditing();
|
|
||||||
//collaborator.open_file( )
|
|
||||||
content = codiad.editor.getContent()
|
|
||||||
codiad.editor.setContent( '' )
|
|
||||||
collaborator.send_init( content )
|
|
||||||
|
|
||||||
// registering change callback
|
|
||||||
editor.addEventListener( "change", handle_change );
|
|
||||||
|
|
||||||
//editor.setTheme( "ace/theme/monokai") ;
|
|
||||||
editor.$blockScrolling = Infinity;
|
|
||||||
|
|
||||||
//collaborator.dump_buffer();
|
|
||||||
let dumped_content = null;
|
|
||||||
|
|
||||||
|
|
||||||
dumped_content = codiad.editor.getContent()
|
|
||||||
collaborator.dump_buffer();
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
collaborator = new Collaborator( session_id );
|
|
||||||
collaborator.send_init()
|
|
||||||
|
|
||||||
if( window.collaboration_socket !== null ) {
|
|
||||||
|
|
||||||
window.collaboration_socket.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Subscribe to know when a file is being closed. */
|
|
||||||
amplify.subscribe('active.onClose', function (path) {
|
|
||||||
|
|
||||||
close()
|
|
||||||
});
|
|
||||||
|
|
||||||
$(window).blur(function() {
|
|
||||||
|
|
||||||
if( editor !== null ) {
|
|
||||||
coords = editor.getCursorPosition();
|
|
||||||
if( coords.row !== 0 && coords.column !== 0 ) {
|
|
||||||
cursor = editor.getCursorPosition();
|
|
||||||
cursor.row = cursor.row + 1
|
|
||||||
console.log( 'Cursor at: ' + cursor.row + ", " + cursor.column );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close();
|
|
||||||
});
|
|
||||||
|
|
||||||
/* When the window is clicked get the cursor position.
|
|
||||||
$(window).click(function () {
|
|
||||||
|
|
||||||
coords = editor.getCursorPosition();
|
|
||||||
if( coords.row !== 0 && coords.column !== 0 ) {
|
|
||||||
//cursor = editor.getCursorPosition();
|
|
||||||
//cursor.row = cursor.row + 1
|
|
||||||
//console.log( 'Cursor at: ' + cursor.row + ", " + cursor.column );
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
/* Subscribe to know when a file become active. */
|
|
||||||
amplify.subscribe('active.onFocus', function (path) {
|
|
||||||
|
|
||||||
just_opened = true;
|
|
||||||
|
|
||||||
if( current_editor !== codiad.active.getPath() && current_editor !== null ) {
|
|
||||||
|
|
||||||
cursor = null;
|
|
||||||
console.log( 'Closing Socket' );
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
console.log( 'Last Editor: ' + current_editor );
|
|
||||||
|
|
||||||
if( loaded === false ) {
|
|
||||||
|
|
||||||
console.log( 'Loading Body' );
|
|
||||||
body_loaded();
|
|
||||||
}
|
|
||||||
console.log( 'Focused Editor: ' + codiad.active.getPath() );
|
|
||||||
|
|
||||||
coords = editor.getCursorPosition();
|
|
||||||
if( coords.row !== 0 && coords.column !== 0 ) {
|
|
||||||
cursor = editor.getCursorPosition();
|
|
||||||
cursor.row = cursor.row + 1
|
|
||||||
console.log( 'Cursor at: ' + cursor.row + ", " + cursor.column );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Collaborative Component for Codiad
|
|
||||||
// ---------------------------------
|
|
||||||
// Displays in real time the selection position and
|
|
||||||
// the changes when concurrently editing files.
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
codiad.collaborative = {
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
})(this, jQuery);
|
|
|
@ -1,205 +0,0 @@
|
||||||
// config variables
|
|
||||||
verbose = false ;
|
|
||||||
session_directory = "./sessions"; // it has to exist
|
|
||||||
|
|
||||||
/* https specific */
|
|
||||||
var https = require( 'https' ),
|
|
||||||
fs = require( 'fs' );
|
|
||||||
|
|
||||||
var options = {
|
|
||||||
key: fs.readFileSync( '/etc/letsencrypt/live/local.telaaedifex.com/privkey.pem' ),
|
|
||||||
cert: fs.readFileSync( '/etc/letsencrypt/live/local.telaaedifex.com/fullchain.pem' ),
|
|
||||||
ca: fs.readFileSync( '/etc/letsencrypt/live/local.telaaedifex.com/chain.pem' )
|
|
||||||
};
|
|
||||||
var app = https.createServer( options );
|
|
||||||
io = require( 'socket.io' ).listen( app ); //socket.io server listens to https connections
|
|
||||||
app.listen( 1337, "0.0.0.0" );
|
|
||||||
|
|
||||||
// will use the following for file IO
|
|
||||||
var fs = require( "fs" ) ;
|
|
||||||
|
|
||||||
//io = require('socket.io').listen(2015) ;
|
|
||||||
if( verbose ) { console.log( "> server launched" ); }
|
|
||||||
|
|
||||||
var init = false;
|
|
||||||
collaborations = [] ;
|
|
||||||
socket_id_to_session_id = [] ;
|
|
||||||
|
|
||||||
io.sockets.on('connection', function(socket) {
|
|
||||||
|
|
||||||
init = false
|
|
||||||
var file = socket.handshake.query.file;
|
|
||||||
//var session_id = socket.handshake.query.session_id;
|
|
||||||
var session_id = socket.handshake.query.file;
|
|
||||||
socket_id_to_session_id[socket.id] = session_id ;
|
|
||||||
|
|
||||||
if( verbose ) { console.log( session_id + "connected on socket" + socket.id ) ; }
|
|
||||||
|
|
||||||
|
|
||||||
if( !( session_id in collaborations ) ) {
|
|
||||||
// not in memory but is is on the filesystem?
|
|
||||||
if( file_exists(session_directory + "/" + session_id) ) {
|
|
||||||
if( verbose ) { console.log( "session terminated previously, pulling back from filesystem" ); }
|
|
||||||
|
|
||||||
var data = read_file( session_directory + "/" + session_id );
|
|
||||||
if( data !== false ) {
|
|
||||||
|
|
||||||
init = false;
|
|
||||||
collaborations[session_id] = {'cached_instructions':JSON.parse(data), 'participants':[]};
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// something went wrong, we start from scratch
|
|
||||||
init = true;
|
|
||||||
collaborations[session_id] = {'cached_instructions':[], 'participants':[]};
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if( verbose ) { console.log( " creating new session" ) ; }
|
|
||||||
init = true;
|
|
||||||
collaborations[session_id] = {'cached_instructions':[], 'participants':[]};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var i = 0;
|
|
||||||
|
|
||||||
for( i=0 ; i<collaborations[session_id]['participants'].length ; i++ ) {
|
|
||||||
if( socket.id!=collaborations[session_id]['participants'][i] ) {
|
|
||||||
io.sockets.connected[collaborations[session_id]['participants'][i]].emit( "recieve_content" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
collaborations[session_id]['participants'].push( socket.id );
|
|
||||||
|
|
||||||
for( i=0 ; i<collaborations[session_id]['participants'].length ; i++ ) {
|
|
||||||
if( socket.id!=collaborations[session_id]['participants'][i] ) {
|
|
||||||
io.sockets.connected[collaborations[session_id]['participants'][i]].emit( "unlock" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.on('change', function( delta ) {
|
|
||||||
if( verbose ) { console.log( "change " + socket_id_to_session_id[socket.id] + " " + delta ) ; }
|
|
||||||
if( socket_id_to_session_id[socket.id] in collaborations ) {
|
|
||||||
collaborations[socket_id_to_session_id[socket.id]]['cached_instructions'].push( ["change", delta, Date.now()] ) ;
|
|
||||||
for( var i=0 ; i<collaborations[session_id]['participants'].length ; i++ ) {
|
|
||||||
if( socket.id!=collaborations[session_id]['participants'][i] ) {
|
|
||||||
io.sockets.connected[collaborations[session_id]['participants'][i]].emit( "change", delta ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if( verbose ) { console.log( "WARNING: could not tie socket_id to any collaboration" ) ; }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
socket.on('change_selection', function( selections ) {
|
|
||||||
if( verbose ) { console.log( "change_selection " + socket_id_to_session_id[socket.id] + " " + selections ) ; }
|
|
||||||
if( socket_id_to_session_id[socket.id] in collaborations ) {
|
|
||||||
for( var i=0 ; i<collaborations[session_id]['participants'].length ; i++ ) {
|
|
||||||
if( socket.id!=collaborations[session_id]['participants'][i] ) {
|
|
||||||
io.sockets.connected[collaborations[session_id]['participants'][i]].emit( "change_selection", selections ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if( verbose ) { console.log( "WARNING: could not tie socket_id to any collaboration" ) ; }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
socket.on('clear_buffer', function() {
|
|
||||||
if( verbose ) { console.log( "clear_buffer " + socket_id_to_session_id[socket.id] ) ; }
|
|
||||||
if( socket_id_to_session_id[socket.id] in collaborations ) {
|
|
||||||
collaborations[socket_id_to_session_id[socket.id]]['cached_instructions'] = [] ;
|
|
||||||
for( var i=0 ; i<collaborations[session_id]['participants'].length ; i++ ) {
|
|
||||||
if( socket.id!=collaborations[session_id]['participants'][i] ) {
|
|
||||||
io.sockets.connected[collaborations[session_id]['participants'][i]].emit( "clear_buffer" ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if( verbose ) { console.log( "WARNING: could not tie socket_id to any collaboration" ) ; }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
socket.on('dump_buffer', function() {
|
|
||||||
if( verbose ) { console.log( "dump_buffer " + socket_id_to_session_id[socket.id] ) ; }
|
|
||||||
|
|
||||||
if( socket_id_to_session_id[socket.id] in collaborations ) {
|
|
||||||
for( var i=0 ; i<collaborations[socket_id_to_session_id[socket.id]]['cached_instructions'].length ; i++ ) {
|
|
||||||
socket.emit( collaborations[socket_id_to_session_id[socket.id]]['cached_instructions'][i][0], collaborations[socket_id_to_session_id[socket.id]]['cached_instructions'][i][1] ) ;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if( verbose ) { console.log( "WARNING: could not tie socket_id to any collaboration" ) ; }
|
|
||||||
}
|
|
||||||
socket.emit( "buffer_dumped" ) ;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
socket.on('disconnect', function () {
|
|
||||||
console.log( socket_id_to_session_id[socket.id] + " disconnected" ) ;
|
|
||||||
var found_and_removed = false ;
|
|
||||||
if( socket_id_to_session_id[socket.id] in collaborations ) {
|
|
||||||
//var index = collaborations[socket_id_to_session_id[socket.id]].participants.indexOf( socket.id ) ;
|
|
||||||
var index = collaborations[socket_id_to_session_id[socket.id]]['participants'].indexOf( socket.id ) ;
|
|
||||||
if( index>-1 ) {
|
|
||||||
//collaborations[socket_id_to_session_id[socket.id]].participants.splice( index, 1 ) ;
|
|
||||||
collaborations[socket_id_to_session_id[socket.id]]['participants'].splice( index, 1 ) ;
|
|
||||||
found_and_removed = true ;
|
|
||||||
//if( collaborations[socket_id_to_session_id[socket.id]].participants.length==0 ) {
|
|
||||||
if( collaborations[socket_id_to_session_id[socket.id]]['participants'].length==0 ) {
|
|
||||||
if( verbose ) { console.log( "last participant in collaboration, committing to disk & removing from memory" ) ; }
|
|
||||||
// no one is left in this session, we commit it to disk & remove it from memory
|
|
||||||
write_file( session_directory + "/" + socket_id_to_session_id[socket.id], JSON.stringify(collaborations[socket_id_to_session_id[socket.id]]['cached_instructions']) ) ;
|
|
||||||
delete collaborations[socket_id_to_session_id[socket.id]] ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( !found_and_removed ) {
|
|
||||||
console.log( "WARNING: could not tie socket_id to any collaboration" ) ;
|
|
||||||
}
|
|
||||||
console.log( collaborations ) ;
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('send_init', function ( delta ) {
|
|
||||||
|
|
||||||
let response = {
|
|
||||||
"message": "setting initial",
|
|
||||||
"initial": init,
|
|
||||||
"content": `${delta}`
|
|
||||||
}
|
|
||||||
socket.emit('recieve_init', JSON.stringify( response ) );
|
|
||||||
init = false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function write_file( path, data ) {
|
|
||||||
try {
|
|
||||||
fs.writeFileSync( path, data ) ;
|
|
||||||
return true ;
|
|
||||||
} catch( e ) {
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function read_file( path ) {
|
|
||||||
try {
|
|
||||||
var data = fs.readFileSync( path ) ;
|
|
||||||
return data ;
|
|
||||||
} catch( e ) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function file_exists( path ) {
|
|
||||||
try {
|
|
||||||
stats = fs.lstatSync( path ) ;
|
|
||||||
if (stats.isFile()) {
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
} catch( e ) {
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
// we should not reach that point
|
|
||||||
return false ;
|
|
||||||
}
|
|
Loading…
Reference in a new issue