comparison backends/directory.js @ 43:023f767662d3

Fix compatibility with strict mode of node 0.4 and some files without licence header.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 01 Mar 2011 11:58:15 +0100
parents dcf1f09f8cee
children fd69d35cf2e6
comparison
equal deleted inserted replaced
42:07ca0263a53f 43:023f767662d3
15 * 15 *
16 * You should have received a copy of the GNU Affero General Public License 16 * You should have received a copy of the GNU Affero General Public License
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. 17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>.
18 */ 18 */
19 19
20 'use strict';
21
20 var fs = require('fs'); 22 var fs = require('fs');
21 var Node = require('../nodes').Node; 23 var Node = require('../nodes').Node;
22 var backend = exports; 24 var backend = exports;
23 25
24 backend.save = function(dir) { 26 backend.save = function(dir) {
25 if (!dir) 27 if (!dir)
26 dir = 'storage'; 28 dir = 'storage';
27 29
28 fs.stat(dir, function(err, stats) { 30 fs.stat(dir, function(err, stats) {
29 if (err) 31 if (err)
30 fs.mkdir(dir, 0755); 32 fs.mkdir(dir, 509); // 0755 in decimal
31 else if (!stats.isDirectory()) { 33 else if (!stats.isDirectory()) {
32 console.log('\033[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\033[0m'); 34 console.log('\x1b[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\x1b[0m');
33 process.exit(1); 35 process.exit(1);
34 } 36 }
35 37
36 fs.readdir(dir, function(err, files) { 38 fs.readdir(dir, function(err, files) {
37 function sanitize(o) { 39 function sanitize(o) {
75 if (!dir) 77 if (!dir)
76 dir = 'storage'; 78 dir = 'storage';
77 79
78 fs.stat(dir, function(err, stats) { 80 fs.stat(dir, function(err, stats) {
79 if (err) 81 if (err)
80 fs.mkdir(dir, 0755); 82 fs.mkdir(dir, 509); // 0755 in decimal
81 else if (!stats.isDirectory()) { 83 else if (!stats.isDirectory()) {
82 console.log('\033[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\033[0m'); 84 console.log('\x1b[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\x1b[0m');
83 process.exit(1); 85 process.exit(1);
84 } 86 }
85 87
86 fs.readdir(dir, function(err, files) { 88 fs.readdir(dir, function(err, files) {
87 var xmpp = require('xmpp'); 89 var xmpp = require('xmpp');