최예리

이미지 업로드 구현 성공

폴더 생성, 수정, 삭제 개선
1 +node_modules
...\ No newline at end of file ...\ No newline at end of file
1 +Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2 +Permission is hereby granted, free of charge, to any person obtaining a copy
3 +of this software and associated documentation files (the "Software"), to
4 +deal in the Software without restriction, including without limitation the
5 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6 +sell copies of the Software, and to permit persons to whom the Software is
7 +furnished to do so, subject to the following conditions:
8 +
9 +The above copyright notice and this permission notice shall be included in
10 +all copies or substantial portions of the Software.
11 +
12 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
18 +IN THE SOFTWARE.
1 +# path
2 +
3 +This is an exact copy of the NodeJS ’path’ module published to the NPM registry.
4 +
5 +[Documentation](http://nodejs.org/docs/latest/api/path.html)
6 +
7 +## Install
8 +
9 +```sh
10 +$ npm install --save path
11 +```
12 +
13 +## License
14 +
15 +MIT
1 +{
2 + "_from": "path",
3 + "_id": "path@0.12.7",
4 + "_inBundle": false,
5 + "_integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=",
6 + "_location": "/path",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "tag",
10 + "registry": true,
11 + "raw": "path",
12 + "name": "path",
13 + "escapedName": "path",
14 + "rawSpec": "",
15 + "saveSpec": null,
16 + "fetchSpec": "latest"
17 + },
18 + "_requiredBy": [
19 + "#USER",
20 + "/"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
23 + "_shasum": "d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f",
24 + "_spec": "path",
25 + "_where": "C:\\Users\\yeari\\Desktop\\경희대\\오픈소스SW개발\\Project\\OSS-Project",
26 + "author": {
27 + "name": "Joyent",
28 + "url": "http://www.joyent.com"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/jinder/path/issues"
32 + },
33 + "bundleDependencies": false,
34 + "dependencies": {
35 + "process": "^0.11.1",
36 + "util": "^0.10.3"
37 + },
38 + "deprecated": false,
39 + "description": "Node.JS path module",
40 + "homepage": "http://nodejs.org/docs/latest/api/path.html",
41 + "keywords": [
42 + "ender",
43 + "path"
44 + ],
45 + "license": "MIT",
46 + "main": "./path.js",
47 + "name": "path",
48 + "repository": {
49 + "type": "git",
50 + "url": "git://github.com/jinder/path.git"
51 + },
52 + "version": "0.12.7"
53 +}
1 +// Copyright Joyent, Inc. and other Node contributors.
2 +//
3 +// Permission is hereby granted, free of charge, to any person obtaining a
4 +// copy of this software and associated documentation files (the
5 +// "Software"), to deal in the Software without restriction, including
6 +// without limitation the rights to use, copy, modify, merge, publish,
7 +// distribute, sublicense, and/or sell copies of the Software, and to permit
8 +// persons to whom the Software is furnished to do so, subject to the
9 +// following conditions:
10 +//
11 +// The above copyright notice and this permission notice shall be included
12 +// in all copies or substantial portions of the Software.
13 +//
14 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 +// USE OR OTHER DEALINGS IN THE SOFTWARE.
21 +
22 +'use strict';
23 +
24 +
25 +var isWindows = process.platform === 'win32';
26 +var util = require('util');
27 +
28 +
29 +// resolves . and .. elements in a path array with directory names there
30 +// must be no slashes or device names (c:\) in the array
31 +// (so also no leading and trailing slashes - it does not distinguish
32 +// relative and absolute paths)
33 +function normalizeArray(parts, allowAboveRoot) {
34 + var res = [];
35 + for (var i = 0; i < parts.length; i++) {
36 + var p = parts[i];
37 +
38 + // ignore empty parts
39 + if (!p || p === '.')
40 + continue;
41 +
42 + if (p === '..') {
43 + if (res.length && res[res.length - 1] !== '..') {
44 + res.pop();
45 + } else if (allowAboveRoot) {
46 + res.push('..');
47 + }
48 + } else {
49 + res.push(p);
50 + }
51 + }
52 +
53 + return res;
54 +}
55 +
56 +// returns an array with empty elements removed from either end of the input
57 +// array or the original array if no elements need to be removed
58 +function trimArray(arr) {
59 + var lastIndex = arr.length - 1;
60 + var start = 0;
61 + for (; start <= lastIndex; start++) {
62 + if (arr[start])
63 + break;
64 + }
65 +
66 + var end = lastIndex;
67 + for (; end >= 0; end--) {
68 + if (arr[end])
69 + break;
70 + }
71 +
72 + if (start === 0 && end === lastIndex)
73 + return arr;
74 + if (start > end)
75 + return [];
76 + return arr.slice(start, end + 1);
77 +}
78 +
79 +// Regex to split a windows path into three parts: [*, device, slash,
80 +// tail] windows-only
81 +var splitDeviceRe =
82 + /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
83 +
84 +// Regex to split the tail part of the above into [*, dir, basename, ext]
85 +var splitTailRe =
86 + /^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
87 +
88 +var win32 = {};
89 +
90 +// Function to split a filename into [root, dir, basename, ext]
91 +function win32SplitPath(filename) {
92 + // Separate device+slash from tail
93 + var result = splitDeviceRe.exec(filename),
94 + device = (result[1] || '') + (result[2] || ''),
95 + tail = result[3] || '';
96 + // Split the tail into dir, basename and extension
97 + var result2 = splitTailRe.exec(tail),
98 + dir = result2[1],
99 + basename = result2[2],
100 + ext = result2[3];
101 + return [device, dir, basename, ext];
102 +}
103 +
104 +function win32StatPath(path) {
105 + var result = splitDeviceRe.exec(path),
106 + device = result[1] || '',
107 + isUnc = !!device && device[1] !== ':';
108 + return {
109 + device: device,
110 + isUnc: isUnc,
111 + isAbsolute: isUnc || !!result[2], // UNC paths are always absolute
112 + tail: result[3]
113 + };
114 +}
115 +
116 +function normalizeUNCRoot(device) {
117 + return '\\\\' + device.replace(/^[\\\/]+/, '').replace(/[\\\/]+/g, '\\');
118 +}
119 +
120 +// path.resolve([from ...], to)
121 +win32.resolve = function() {
122 + var resolvedDevice = '',
123 + resolvedTail = '',
124 + resolvedAbsolute = false;
125 +
126 + for (var i = arguments.length - 1; i >= -1; i--) {
127 + var path;
128 + if (i >= 0) {
129 + path = arguments[i];
130 + } else if (!resolvedDevice) {
131 + path = process.cwd();
132 + } else {
133 + // Windows has the concept of drive-specific current working
134 + // directories. If we've resolved a drive letter but not yet an
135 + // absolute path, get cwd for that drive. We're sure the device is not
136 + // an unc path at this points, because unc paths are always absolute.
137 + path = process.env['=' + resolvedDevice];
138 + // Verify that a drive-local cwd was found and that it actually points
139 + // to our drive. If not, default to the drive's root.
140 + if (!path || path.substr(0, 3).toLowerCase() !==
141 + resolvedDevice.toLowerCase() + '\\') {
142 + path = resolvedDevice + '\\';
143 + }
144 + }
145 +
146 + // Skip empty and invalid entries
147 + if (!util.isString(path)) {
148 + throw new TypeError('Arguments to path.resolve must be strings');
149 + } else if (!path) {
150 + continue;
151 + }
152 +
153 + var result = win32StatPath(path),
154 + device = result.device,
155 + isUnc = result.isUnc,
156 + isAbsolute = result.isAbsolute,
157 + tail = result.tail;
158 +
159 + if (device &&
160 + resolvedDevice &&
161 + device.toLowerCase() !== resolvedDevice.toLowerCase()) {
162 + // This path points to another device so it is not applicable
163 + continue;
164 + }
165 +
166 + if (!resolvedDevice) {
167 + resolvedDevice = device;
168 + }
169 + if (!resolvedAbsolute) {
170 + resolvedTail = tail + '\\' + resolvedTail;
171 + resolvedAbsolute = isAbsolute;
172 + }
173 +
174 + if (resolvedDevice && resolvedAbsolute) {
175 + break;
176 + }
177 + }
178 +
179 + // Convert slashes to backslashes when `resolvedDevice` points to an UNC
180 + // root. Also squash multiple slashes into a single one where appropriate.
181 + if (isUnc) {
182 + resolvedDevice = normalizeUNCRoot(resolvedDevice);
183 + }
184 +
185 + // At this point the path should be resolved to a full absolute path,
186 + // but handle relative paths to be safe (might happen when process.cwd()
187 + // fails)
188 +
189 + // Normalize the tail path
190 + resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/),
191 + !resolvedAbsolute).join('\\');
192 +
193 + return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
194 + '.';
195 +};
196 +
197 +
198 +win32.normalize = function(path) {
199 + var result = win32StatPath(path),
200 + device = result.device,
201 + isUnc = result.isUnc,
202 + isAbsolute = result.isAbsolute,
203 + tail = result.tail,
204 + trailingSlash = /[\\\/]$/.test(tail);
205 +
206 + // Normalize the tail path
207 + tail = normalizeArray(tail.split(/[\\\/]+/), !isAbsolute).join('\\');
208 +
209 + if (!tail && !isAbsolute) {
210 + tail = '.';
211 + }
212 + if (tail && trailingSlash) {
213 + tail += '\\';
214 + }
215 +
216 + // Convert slashes to backslashes when `device` points to an UNC root.
217 + // Also squash multiple slashes into a single one where appropriate.
218 + if (isUnc) {
219 + device = normalizeUNCRoot(device);
220 + }
221 +
222 + return device + (isAbsolute ? '\\' : '') + tail;
223 +};
224 +
225 +
226 +win32.isAbsolute = function(path) {
227 + return win32StatPath(path).isAbsolute;
228 +};
229 +
230 +win32.join = function() {
231 + var paths = [];
232 + for (var i = 0; i < arguments.length; i++) {
233 + var arg = arguments[i];
234 + if (!util.isString(arg)) {
235 + throw new TypeError('Arguments to path.join must be strings');
236 + }
237 + if (arg) {
238 + paths.push(arg);
239 + }
240 + }
241 +
242 + var joined = paths.join('\\');
243 +
244 + // Make sure that the joined path doesn't start with two slashes, because
245 + // normalize() will mistake it for an UNC path then.
246 + //
247 + // This step is skipped when it is very clear that the user actually
248 + // intended to point at an UNC path. This is assumed when the first
249 + // non-empty string arguments starts with exactly two slashes followed by
250 + // at least one more non-slash character.
251 + //
252 + // Note that for normalize() to treat a path as an UNC path it needs to
253 + // have at least 2 components, so we don't filter for that here.
254 + // This means that the user can use join to construct UNC paths from
255 + // a server name and a share name; for example:
256 + // path.join('//server', 'share') -> '\\\\server\\share\')
257 + if (!/^[\\\/]{2}[^\\\/]/.test(paths[0])) {
258 + joined = joined.replace(/^[\\\/]{2,}/, '\\');
259 + }
260 +
261 + return win32.normalize(joined);
262 +};
263 +
264 +
265 +// path.relative(from, to)
266 +// it will solve the relative path from 'from' to 'to', for instance:
267 +// from = 'C:\\orandea\\test\\aaa'
268 +// to = 'C:\\orandea\\impl\\bbb'
269 +// The output of the function should be: '..\\..\\impl\\bbb'
270 +win32.relative = function(from, to) {
271 + from = win32.resolve(from);
272 + to = win32.resolve(to);
273 +
274 + // windows is not case sensitive
275 + var lowerFrom = from.toLowerCase();
276 + var lowerTo = to.toLowerCase();
277 +
278 + var toParts = trimArray(to.split('\\'));
279 +
280 + var lowerFromParts = trimArray(lowerFrom.split('\\'));
281 + var lowerToParts = trimArray(lowerTo.split('\\'));
282 +
283 + var length = Math.min(lowerFromParts.length, lowerToParts.length);
284 + var samePartsLength = length;
285 + for (var i = 0; i < length; i++) {
286 + if (lowerFromParts[i] !== lowerToParts[i]) {
287 + samePartsLength = i;
288 + break;
289 + }
290 + }
291 +
292 + if (samePartsLength == 0) {
293 + return to;
294 + }
295 +
296 + var outputParts = [];
297 + for (var i = samePartsLength; i < lowerFromParts.length; i++) {
298 + outputParts.push('..');
299 + }
300 +
301 + outputParts = outputParts.concat(toParts.slice(samePartsLength));
302 +
303 + return outputParts.join('\\');
304 +};
305 +
306 +
307 +win32._makeLong = function(path) {
308 + // Note: this will *probably* throw somewhere.
309 + if (!util.isString(path))
310 + return path;
311 +
312 + if (!path) {
313 + return '';
314 + }
315 +
316 + var resolvedPath = win32.resolve(path);
317 +
318 + if (/^[a-zA-Z]\:\\/.test(resolvedPath)) {
319 + // path is local filesystem path, which needs to be converted
320 + // to long UNC path.
321 + return '\\\\?\\' + resolvedPath;
322 + } else if (/^\\\\[^?.]/.test(resolvedPath)) {
323 + // path is network UNC path, which needs to be converted
324 + // to long UNC path.
325 + return '\\\\?\\UNC\\' + resolvedPath.substring(2);
326 + }
327 +
328 + return path;
329 +};
330 +
331 +
332 +win32.dirname = function(path) {
333 + var result = win32SplitPath(path),
334 + root = result[0],
335 + dir = result[1];
336 +
337 + if (!root && !dir) {
338 + // No dirname whatsoever
339 + return '.';
340 + }
341 +
342 + if (dir) {
343 + // It has a dirname, strip trailing slash
344 + dir = dir.substr(0, dir.length - 1);
345 + }
346 +
347 + return root + dir;
348 +};
349 +
350 +
351 +win32.basename = function(path, ext) {
352 + var f = win32SplitPath(path)[2];
353 + // TODO: make this comparison case-insensitive on windows?
354 + if (ext && f.substr(-1 * ext.length) === ext) {
355 + f = f.substr(0, f.length - ext.length);
356 + }
357 + return f;
358 +};
359 +
360 +
361 +win32.extname = function(path) {
362 + return win32SplitPath(path)[3];
363 +};
364 +
365 +
366 +win32.format = function(pathObject) {
367 + if (!util.isObject(pathObject)) {
368 + throw new TypeError(
369 + "Parameter 'pathObject' must be an object, not " + typeof pathObject
370 + );
371 + }
372 +
373 + var root = pathObject.root || '';
374 +
375 + if (!util.isString(root)) {
376 + throw new TypeError(
377 + "'pathObject.root' must be a string or undefined, not " +
378 + typeof pathObject.root
379 + );
380 + }
381 +
382 + var dir = pathObject.dir;
383 + var base = pathObject.base || '';
384 + if (!dir) {
385 + return base;
386 + }
387 + if (dir[dir.length - 1] === win32.sep) {
388 + return dir + base;
389 + }
390 + return dir + win32.sep + base;
391 +};
392 +
393 +
394 +win32.parse = function(pathString) {
395 + if (!util.isString(pathString)) {
396 + throw new TypeError(
397 + "Parameter 'pathString' must be a string, not " + typeof pathString
398 + );
399 + }
400 + var allParts = win32SplitPath(pathString);
401 + if (!allParts || allParts.length !== 4) {
402 + throw new TypeError("Invalid path '" + pathString + "'");
403 + }
404 + return {
405 + root: allParts[0],
406 + dir: allParts[0] + allParts[1].slice(0, -1),
407 + base: allParts[2],
408 + ext: allParts[3],
409 + name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
410 + };
411 +};
412 +
413 +
414 +win32.sep = '\\';
415 +win32.delimiter = ';';
416 +
417 +
418 +// Split a filename into [root, dir, basename, ext], unix version
419 +// 'root' is just a slash, or nothing.
420 +var splitPathRe =
421 + /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
422 +var posix = {};
423 +
424 +
425 +function posixSplitPath(filename) {
426 + return splitPathRe.exec(filename).slice(1);
427 +}
428 +
429 +
430 +// path.resolve([from ...], to)
431 +// posix version
432 +posix.resolve = function() {
433 + var resolvedPath = '',
434 + resolvedAbsolute = false;
435 +
436 + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
437 + var path = (i >= 0) ? arguments[i] : process.cwd();
438 +
439 + // Skip empty and invalid entries
440 + if (!util.isString(path)) {
441 + throw new TypeError('Arguments to path.resolve must be strings');
442 + } else if (!path) {
443 + continue;
444 + }
445 +
446 + resolvedPath = path + '/' + resolvedPath;
447 + resolvedAbsolute = path[0] === '/';
448 + }
449 +
450 + // At this point the path should be resolved to a full absolute path, but
451 + // handle relative paths to be safe (might happen when process.cwd() fails)
452 +
453 + // Normalize the path
454 + resolvedPath = normalizeArray(resolvedPath.split('/'),
455 + !resolvedAbsolute).join('/');
456 +
457 + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
458 +};
459 +
460 +// path.normalize(path)
461 +// posix version
462 +posix.normalize = function(path) {
463 + var isAbsolute = posix.isAbsolute(path),
464 + trailingSlash = path && path[path.length - 1] === '/';
465 +
466 + // Normalize the path
467 + path = normalizeArray(path.split('/'), !isAbsolute).join('/');
468 +
469 + if (!path && !isAbsolute) {
470 + path = '.';
471 + }
472 + if (path && trailingSlash) {
473 + path += '/';
474 + }
475 +
476 + return (isAbsolute ? '/' : '') + path;
477 +};
478 +
479 +// posix version
480 +posix.isAbsolute = function(path) {
481 + return path.charAt(0) === '/';
482 +};
483 +
484 +// posix version
485 +posix.join = function() {
486 + var path = '';
487 + for (var i = 0; i < arguments.length; i++) {
488 + var segment = arguments[i];
489 + if (!util.isString(segment)) {
490 + throw new TypeError('Arguments to path.join must be strings');
491 + }
492 + if (segment) {
493 + if (!path) {
494 + path += segment;
495 + } else {
496 + path += '/' + segment;
497 + }
498 + }
499 + }
500 + return posix.normalize(path);
501 +};
502 +
503 +
504 +// path.relative(from, to)
505 +// posix version
506 +posix.relative = function(from, to) {
507 + from = posix.resolve(from).substr(1);
508 + to = posix.resolve(to).substr(1);
509 +
510 + var fromParts = trimArray(from.split('/'));
511 + var toParts = trimArray(to.split('/'));
512 +
513 + var length = Math.min(fromParts.length, toParts.length);
514 + var samePartsLength = length;
515 + for (var i = 0; i < length; i++) {
516 + if (fromParts[i] !== toParts[i]) {
517 + samePartsLength = i;
518 + break;
519 + }
520 + }
521 +
522 + var outputParts = [];
523 + for (var i = samePartsLength; i < fromParts.length; i++) {
524 + outputParts.push('..');
525 + }
526 +
527 + outputParts = outputParts.concat(toParts.slice(samePartsLength));
528 +
529 + return outputParts.join('/');
530 +};
531 +
532 +
533 +posix._makeLong = function(path) {
534 + return path;
535 +};
536 +
537 +
538 +posix.dirname = function(path) {
539 + var result = posixSplitPath(path),
540 + root = result[0],
541 + dir = result[1];
542 +
543 + if (!root && !dir) {
544 + // No dirname whatsoever
545 + return '.';
546 + }
547 +
548 + if (dir) {
549 + // It has a dirname, strip trailing slash
550 + dir = dir.substr(0, dir.length - 1);
551 + }
552 +
553 + return root + dir;
554 +};
555 +
556 +
557 +posix.basename = function(path, ext) {
558 + var f = posixSplitPath(path)[2];
559 + // TODO: make this comparison case-insensitive on windows?
560 + if (ext && f.substr(-1 * ext.length) === ext) {
561 + f = f.substr(0, f.length - ext.length);
562 + }
563 + return f;
564 +};
565 +
566 +
567 +posix.extname = function(path) {
568 + return posixSplitPath(path)[3];
569 +};
570 +
571 +
572 +posix.format = function(pathObject) {
573 + if (!util.isObject(pathObject)) {
574 + throw new TypeError(
575 + "Parameter 'pathObject' must be an object, not " + typeof pathObject
576 + );
577 + }
578 +
579 + var root = pathObject.root || '';
580 +
581 + if (!util.isString(root)) {
582 + throw new TypeError(
583 + "'pathObject.root' must be a string or undefined, not " +
584 + typeof pathObject.root
585 + );
586 + }
587 +
588 + var dir = pathObject.dir ? pathObject.dir + posix.sep : '';
589 + var base = pathObject.base || '';
590 + return dir + base;
591 +};
592 +
593 +
594 +posix.parse = function(pathString) {
595 + if (!util.isString(pathString)) {
596 + throw new TypeError(
597 + "Parameter 'pathString' must be a string, not " + typeof pathString
598 + );
599 + }
600 + var allParts = posixSplitPath(pathString);
601 + if (!allParts || allParts.length !== 4) {
602 + throw new TypeError("Invalid path '" + pathString + "'");
603 + }
604 + allParts[1] = allParts[1] || '';
605 + allParts[2] = allParts[2] || '';
606 + allParts[3] = allParts[3] || '';
607 +
608 + return {
609 + root: allParts[0],
610 + dir: allParts[0] + allParts[1].slice(0, -1),
611 + base: allParts[2],
612 + ext: allParts[3],
613 + name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
614 + };
615 +};
616 +
617 +
618 +posix.sep = '/';
619 +posix.delimiter = ':';
620 +
621 +
622 +if (isWindows)
623 + module.exports = win32;
624 +else /* posix */
625 + module.exports = posix;
626 +
627 +module.exports.posix = posix;
628 +module.exports.win32 = win32;
1 +{
2 +extends: "eslint:recommended",
3 + "env": {
4 + "node": true,
5 + "browser": true,
6 + "es6" : true,
7 + "mocha": true
8 + },
9 + "rules": {
10 + "indent": [2, 4],
11 + "brace-style": [2, "1tbs"],
12 + "quotes": [2, "single"],
13 + "no-console": 0,
14 + "no-shadow": 0,
15 + "no-use-before-define": [2, "nofunc"],
16 + "no-underscore-dangle": 0,
17 + "no-constant-condition": 0,
18 + "space-after-function-name": 0,
19 + "consistent-return": 0
20 + }
21 +}
1 +(The MIT License)
2 +
3 +Copyright (c) 2013 Roman Shtylman <shtylman@gmail.com>
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining
6 +a copy of this software and associated documentation files (the
7 +'Software'), to deal in the Software without restriction, including
8 +without limitation the rights to use, copy, modify, merge, publish,
9 +distribute, sublicense, and/or sell copies of the Software, and to
10 +permit persons to whom the Software is furnished to do so, subject to
11 +the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be
14 +included in all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# process
2 +
3 +```require('process');``` just like any other module.
4 +
5 +Works in node.js and browsers via the browser.js shim provided with the module.
6 +
7 +## browser implementation
8 +
9 +The goal of this module is not to be a full-fledged alternative to the builtin process module. This module mostly exists to provide the nextTick functionality and little more. We keep this module lean because it will often be included by default by tools like browserify when it detects a module has used the `process` global.
10 +
11 +It also exposes a "browser" member (i.e. `process.browser`) which is `true` in this implementation but `undefined` in node. This can be used in isomorphic code that adjusts it's behavior depending on which environment it's running in.
12 +
13 +If you are looking to provide other process methods, I suggest you monkey patch them onto the process global in your app. A list of user created patches is below.
14 +
15 +* [hrtime](https://github.com/kumavis/browser-process-hrtime)
16 +* [stdout](https://github.com/kumavis/browser-stdout)
17 +
18 +## package manager notes
19 +
20 +If you are writing a bundler to package modules for client side use, make sure you use the ```browser``` field hint in package.json.
21 +
22 +See https://gist.github.com/4339901 for details.
23 +
24 +The [browserify](https://github.com/substack/node-browserify) module will properly handle this field when bundling your files.
25 +
26 +
1 +// shim for using process in browser
2 +var process = module.exports = {};
3 +
4 +// cached from whatever global is present so that test runners that stub it
5 +// don't break things. But we need to wrap it in a try catch in case it is
6 +// wrapped in strict mode code which doesn't define any globals. It's inside a
7 +// function because try/catches deoptimize in certain engines.
8 +
9 +var cachedSetTimeout;
10 +var cachedClearTimeout;
11 +
12 +function defaultSetTimout() {
13 + throw new Error('setTimeout has not been defined');
14 +}
15 +function defaultClearTimeout () {
16 + throw new Error('clearTimeout has not been defined');
17 +}
18 +(function () {
19 + try {
20 + if (typeof setTimeout === 'function') {
21 + cachedSetTimeout = setTimeout;
22 + } else {
23 + cachedSetTimeout = defaultSetTimout;
24 + }
25 + } catch (e) {
26 + cachedSetTimeout = defaultSetTimout;
27 + }
28 + try {
29 + if (typeof clearTimeout === 'function') {
30 + cachedClearTimeout = clearTimeout;
31 + } else {
32 + cachedClearTimeout = defaultClearTimeout;
33 + }
34 + } catch (e) {
35 + cachedClearTimeout = defaultClearTimeout;
36 + }
37 +} ())
38 +function runTimeout(fun) {
39 + if (cachedSetTimeout === setTimeout) {
40 + //normal enviroments in sane situations
41 + return setTimeout(fun, 0);
42 + }
43 + // if setTimeout wasn't available but was latter defined
44 + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
45 + cachedSetTimeout = setTimeout;
46 + return setTimeout(fun, 0);
47 + }
48 + try {
49 + // when when somebody has screwed with setTimeout but no I.E. maddness
50 + return cachedSetTimeout(fun, 0);
51 + } catch(e){
52 + try {
53 + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
54 + return cachedSetTimeout.call(null, fun, 0);
55 + } catch(e){
56 + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
57 + return cachedSetTimeout.call(this, fun, 0);
58 + }
59 + }
60 +
61 +
62 +}
63 +function runClearTimeout(marker) {
64 + if (cachedClearTimeout === clearTimeout) {
65 + //normal enviroments in sane situations
66 + return clearTimeout(marker);
67 + }
68 + // if clearTimeout wasn't available but was latter defined
69 + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
70 + cachedClearTimeout = clearTimeout;
71 + return clearTimeout(marker);
72 + }
73 + try {
74 + // when when somebody has screwed with setTimeout but no I.E. maddness
75 + return cachedClearTimeout(marker);
76 + } catch (e){
77 + try {
78 + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
79 + return cachedClearTimeout.call(null, marker);
80 + } catch (e){
81 + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
82 + // Some versions of I.E. have different rules for clearTimeout vs setTimeout
83 + return cachedClearTimeout.call(this, marker);
84 + }
85 + }
86 +
87 +
88 +
89 +}
90 +var queue = [];
91 +var draining = false;
92 +var currentQueue;
93 +var queueIndex = -1;
94 +
95 +function cleanUpNextTick() {
96 + if (!draining || !currentQueue) {
97 + return;
98 + }
99 + draining = false;
100 + if (currentQueue.length) {
101 + queue = currentQueue.concat(queue);
102 + } else {
103 + queueIndex = -1;
104 + }
105 + if (queue.length) {
106 + drainQueue();
107 + }
108 +}
109 +
110 +function drainQueue() {
111 + if (draining) {
112 + return;
113 + }
114 + var timeout = runTimeout(cleanUpNextTick);
115 + draining = true;
116 +
117 + var len = queue.length;
118 + while(len) {
119 + currentQueue = queue;
120 + queue = [];
121 + while (++queueIndex < len) {
122 + if (currentQueue) {
123 + currentQueue[queueIndex].run();
124 + }
125 + }
126 + queueIndex = -1;
127 + len = queue.length;
128 + }
129 + currentQueue = null;
130 + draining = false;
131 + runClearTimeout(timeout);
132 +}
133 +
134 +process.nextTick = function (fun) {
135 + var args = new Array(arguments.length - 1);
136 + if (arguments.length > 1) {
137 + for (var i = 1; i < arguments.length; i++) {
138 + args[i - 1] = arguments[i];
139 + }
140 + }
141 + queue.push(new Item(fun, args));
142 + if (queue.length === 1 && !draining) {
143 + runTimeout(drainQueue);
144 + }
145 +};
146 +
147 +// v8 likes predictible objects
148 +function Item(fun, array) {
149 + this.fun = fun;
150 + this.array = array;
151 +}
152 +Item.prototype.run = function () {
153 + this.fun.apply(null, this.array);
154 +};
155 +process.title = 'browser';
156 +process.browser = true;
157 +process.env = {};
158 +process.argv = [];
159 +process.version = ''; // empty string to avoid regexp issues
160 +process.versions = {};
161 +
162 +function noop() {}
163 +
164 +process.on = noop;
165 +process.addListener = noop;
166 +process.once = noop;
167 +process.off = noop;
168 +process.removeListener = noop;
169 +process.removeAllListeners = noop;
170 +process.emit = noop;
171 +process.prependListener = noop;
172 +process.prependOnceListener = noop;
173 +
174 +process.listeners = function (name) { return [] }
175 +
176 +process.binding = function (name) {
177 + throw new Error('process.binding is not supported');
178 +};
179 +
180 +process.cwd = function () { return '/' };
181 +process.chdir = function (dir) {
182 + throw new Error('process.chdir is not supported');
183 +};
184 +process.umask = function() { return 0; };
1 +// for now just expose the builtin process global from node.js
2 +module.exports = global.process;
1 +{
2 + "_from": "process@^0.11.1",
3 + "_id": "process@0.11.10",
4 + "_inBundle": false,
5 + "_integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=",
6 + "_location": "/process",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "process@^0.11.1",
12 + "name": "process",
13 + "escapedName": "process",
14 + "rawSpec": "^0.11.1",
15 + "saveSpec": null,
16 + "fetchSpec": "^0.11.1"
17 + },
18 + "_requiredBy": [
19 + "/path"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
22 + "_shasum": "7332300e840161bda3e69a1d1d91a7d4bc16f182",
23 + "_spec": "process@^0.11.1",
24 + "_where": "C:\\Users\\yeari\\Desktop\\경희대\\오픈소스SW개발\\Project\\OSS-Project\\node_modules\\path",
25 + "author": {
26 + "name": "Roman Shtylman",
27 + "email": "shtylman@gmail.com"
28 + },
29 + "browser": "./browser.js",
30 + "bugs": {
31 + "url": "https://github.com/shtylman/node-process/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "process information for node.js and browsers",
36 + "devDependencies": {
37 + "mocha": "2.2.1",
38 + "zuul": "^3.10.3"
39 + },
40 + "engines": {
41 + "node": ">= 0.6.0"
42 + },
43 + "homepage": "https://github.com/shtylman/node-process#readme",
44 + "keywords": [
45 + "process"
46 + ],
47 + "license": "MIT",
48 + "main": "./index.js",
49 + "name": "process",
50 + "repository": {
51 + "type": "git",
52 + "url": "git://github.com/shtylman/node-process.git"
53 + },
54 + "scripts": {
55 + "browser": "zuul --no-coverage --ui mocha-bdd --local 8080 -- test.js",
56 + "test": "mocha test.js"
57 + },
58 + "version": "0.11.10"
59 +}
1 +var assert = require('assert');
2 +var ourProcess = require('./browser');
3 +describe('test against our process', function () {
4 + test(ourProcess);
5 +});
6 +if (!process.browser) {
7 + describe('test against node', function () {
8 + test(process);
9 + });
10 + vmtest();
11 +}
12 +function test (ourProcess) {
13 + describe('test arguments', function () {
14 + it ('works', function (done) {
15 + var order = 0;
16 +
17 +
18 + ourProcess.nextTick(function (num) {
19 + assert.equal(num, order++, 'first one works');
20 + ourProcess.nextTick(function (num) {
21 + assert.equal(num, order++, 'recursive one is 4th');
22 + }, 3);
23 + }, 0);
24 + ourProcess.nextTick(function (num) {
25 + assert.equal(num, order++, 'second one starts');
26 + ourProcess.nextTick(function (num) {
27 + assert.equal(num, order++, 'this is third');
28 + ourProcess.nextTick(function (num) {
29 + assert.equal(num, order++, 'this is last');
30 + done();
31 + }, 5);
32 + }, 4);
33 + }, 1);
34 + ourProcess.nextTick(function (num) {
35 +
36 + assert.equal(num, order++, '3rd schedualed happens after the error');
37 + }, 2);
38 + });
39 + });
40 +if (!process.browser) {
41 + describe('test errors', function (t) {
42 + it ('works', function (done) {
43 + var order = 0;
44 + process.removeAllListeners('uncaughtException');
45 + process.once('uncaughtException', function(err) {
46 + assert.equal(2, order++, 'error is third');
47 + ourProcess.nextTick(function () {
48 + assert.equal(5, order++, 'schedualed in error is last');
49 + done();
50 + });
51 + });
52 + ourProcess.nextTick(function () {
53 + assert.equal(0, order++, 'first one works');
54 + ourProcess.nextTick(function () {
55 + assert.equal(4, order++, 'recursive one is 4th');
56 + });
57 + });
58 + ourProcess.nextTick(function () {
59 + assert.equal(1, order++, 'second one starts');
60 + throw(new Error('an error is thrown'));
61 + });
62 + ourProcess.nextTick(function () {
63 + assert.equal(3, order++, '3rd schedualed happens after the error');
64 + });
65 + });
66 + });
67 +}
68 + describe('rename globals', function (t) {
69 + var oldTimeout = setTimeout;
70 + var oldClear = clearTimeout;
71 +
72 + it('clearTimeout', function (done){
73 +
74 + var ok = true;
75 + clearTimeout = function () {
76 + ok = false;
77 + }
78 + var ran = false;
79 + function cleanup() {
80 + clearTimeout = oldClear;
81 + var err;
82 + try {
83 + assert.ok(ok, 'fake clearTimeout ran');
84 + assert.ok(ran, 'should have run');
85 + } catch (e) {
86 + err = e;
87 + }
88 + done(err);
89 + }
90 + setTimeout(cleanup, 1000);
91 + ourProcess.nextTick(function () {
92 + ran = true;
93 + });
94 + });
95 + it('just setTimeout', function (done){
96 +
97 +
98 + setTimeout = function () {
99 + setTimeout = oldTimeout;
100 + try {
101 + assert.ok(false, 'fake setTimeout called')
102 + } catch (e) {
103 + done(e);
104 + }
105 +
106 + }
107 +
108 + ourProcess.nextTick(function () {
109 + setTimeout = oldTimeout;
110 + done();
111 + });
112 + });
113 + });
114 +}
115 +function vmtest() {
116 + var vm = require('vm');
117 + var fs = require('fs');
118 + var process = fs.readFileSync('./browser.js', {encoding: 'utf8'});
119 +
120 +
121 + describe('should work in vm in strict mode with no globals', function () {
122 + it('should parse', function (done) {
123 + var str = '"use strict";var module = {exports:{}};';
124 + str += process;
125 + str += 'this.works = process.browser;';
126 + var script = new vm.Script(str);
127 + var context = {
128 + works: false
129 + };
130 + script.runInNewContext(context);
131 + assert.ok(context.works);
132 + done();
133 + });
134 + it('setTimeout throws error', function (done) {
135 + var str = '"use strict";var module = {exports:{}};';
136 + str += process;
137 + str += 'try {process.nextTick(function () {})} catch (e){this.works = e;}';
138 + var script = new vm.Script(str);
139 + var context = {
140 + works: false
141 + };
142 + script.runInNewContext(context);
143 + assert.ok(context.works);
144 + done();
145 + });
146 + it('should generally work', function (done) {
147 + var str = '"use strict";var module = {exports:{}};';
148 + str += process;
149 + str += 'process.nextTick(function () {assert.ok(true);done();})';
150 + var script = new vm.Script(str);
151 + var context = {
152 + clearTimeout: clearTimeout,
153 + setTimeout: setTimeout,
154 + done: done,
155 + assert: assert
156 + };
157 + script.runInNewContext(context);
158 + });
159 + it('late defs setTimeout', function (done) {
160 + var str = '"use strict";var module = {exports:{}};';
161 + str += process;
162 + str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {assert.ok(true);done();})';
163 + var script = new vm.Script(str);
164 + var context = {
165 + clearTimeout: clearTimeout,
166 + hiddenSetTimeout: setTimeout,
167 + done: done,
168 + assert: assert
169 + };
170 + script.runInNewContext(context);
171 + });
172 + it('late defs clearTimeout', function (done) {
173 + var str = '"use strict";var module = {exports:{}};';
174 + str += process;
175 + str += 'var clearTimeout = hiddenClearTimeout;process.nextTick(function () {assert.ok(true);done();})';
176 + var script = new vm.Script(str);
177 + var context = {
178 + hiddenClearTimeout: clearTimeout,
179 + setTimeout: setTimeout,
180 + done: done,
181 + assert: assert
182 + };
183 + script.runInNewContext(context);
184 + });
185 + it('late defs setTimeout and then redefine', function (done) {
186 + var str = '"use strict";var module = {exports:{}};';
187 + str += process;
188 + str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {setTimeout = function (){throw new Error("foo")};hiddenSetTimeout(function(){process.nextTick(function (){assert.ok(true);done();});});});';
189 + var script = new vm.Script(str);
190 + var context = {
191 + clearTimeout: clearTimeout,
192 + hiddenSetTimeout: setTimeout,
193 + done: done,
194 + assert: assert
195 + };
196 + script.runInNewContext(context);
197 + });
198 + });
199 +}
1 +Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2 +Permission is hereby granted, free of charge, to any person obtaining a copy
3 +of this software and associated documentation files (the "Software"), to
4 +deal in the Software without restriction, including without limitation the
5 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6 +sell copies of the Software, and to permit persons to whom the Software is
7 +furnished to do so, subject to the following conditions:
8 +
9 +The above copyright notice and this permission notice shall be included in
10 +all copies or substantial portions of the Software.
11 +
12 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
18 +IN THE SOFTWARE.
1 +# util
2 +
3 +[![Build Status](https://travis-ci.org/defunctzombie/node-util.png?branch=master)](https://travis-ci.org/defunctzombie/node-util)
4 +
5 +node.js [util](http://nodejs.org/api/util.html) module as a module
6 +
7 +## install via [npm](npmjs.org)
8 +
9 +```shell
10 +npm install util
11 +```
12 +
13 +## browser support
14 +
15 +This module also works in modern browsers. If you need legacy browser support you will need to polyfill ES5 features.
1 +{
2 + "_from": "util@^0.10.3",
3 + "_id": "util@0.10.4",
4 + "_inBundle": false,
5 + "_integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
6 + "_location": "/util",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "util@^0.10.3",
12 + "name": "util",
13 + "escapedName": "util",
14 + "rawSpec": "^0.10.3",
15 + "saveSpec": null,
16 + "fetchSpec": "^0.10.3"
17 + },
18 + "_requiredBy": [
19 + "/path"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
22 + "_shasum": "3aa0125bfe668a4672de58857d3ace27ecb76901",
23 + "_spec": "util@^0.10.3",
24 + "_where": "C:\\Users\\yeari\\Desktop\\경희대\\오픈소스SW개발\\Project\\OSS-Project\\node_modules\\path",
25 + "author": {
26 + "name": "Joyent",
27 + "url": "http://www.joyent.com"
28 + },
29 + "browser": {
30 + "./support/isBuffer.js": "./support/isBufferBrowser.js"
31 + },
32 + "bugs": {
33 + "url": "https://github.com/defunctzombie/node-util/issues"
34 + },
35 + "bundleDependencies": false,
36 + "dependencies": {
37 + "inherits": "2.0.3"
38 + },
39 + "deprecated": false,
40 + "description": "Node.JS util module",
41 + "devDependencies": {
42 + "zuul": "~1.0.9"
43 + },
44 + "files": [
45 + "util.js",
46 + "support"
47 + ],
48 + "homepage": "https://github.com/defunctzombie/node-util",
49 + "keywords": [
50 + "util"
51 + ],
52 + "license": "MIT",
53 + "main": "./util.js",
54 + "name": "util",
55 + "repository": {
56 + "type": "git",
57 + "url": "git://github.com/defunctzombie/node-util.git"
58 + },
59 + "scripts": {
60 + "test": "node test/node/*.js && zuul test/browser/*.js"
61 + },
62 + "version": "0.10.4"
63 +}
1 +module.exports = function isBuffer(arg) {
2 + return arg instanceof Buffer;
3 +}
1 +module.exports = function isBuffer(arg) {
2 + return arg && typeof arg === 'object'
3 + && typeof arg.copy === 'function'
4 + && typeof arg.fill === 'function'
5 + && typeof arg.readUInt8 === 'function';
6 +}
...\ No newline at end of file ...\ No newline at end of file
1 +// Copyright Joyent, Inc. and other Node contributors.
2 +//
3 +// Permission is hereby granted, free of charge, to any person obtaining a
4 +// copy of this software and associated documentation files (the
5 +// "Software"), to deal in the Software without restriction, including
6 +// without limitation the rights to use, copy, modify, merge, publish,
7 +// distribute, sublicense, and/or sell copies of the Software, and to permit
8 +// persons to whom the Software is furnished to do so, subject to the
9 +// following conditions:
10 +//
11 +// The above copyright notice and this permission notice shall be included
12 +// in all copies or substantial portions of the Software.
13 +//
14 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 +// USE OR OTHER DEALINGS IN THE SOFTWARE.
21 +
22 +var formatRegExp = /%[sdj%]/g;
23 +exports.format = function(f) {
24 + if (!isString(f)) {
25 + var objects = [];
26 + for (var i = 0; i < arguments.length; i++) {
27 + objects.push(inspect(arguments[i]));
28 + }
29 + return objects.join(' ');
30 + }
31 +
32 + var i = 1;
33 + var args = arguments;
34 + var len = args.length;
35 + var str = String(f).replace(formatRegExp, function(x) {
36 + if (x === '%%') return '%';
37 + if (i >= len) return x;
38 + switch (x) {
39 + case '%s': return String(args[i++]);
40 + case '%d': return Number(args[i++]);
41 + case '%j':
42 + try {
43 + return JSON.stringify(args[i++]);
44 + } catch (_) {
45 + return '[Circular]';
46 + }
47 + default:
48 + return x;
49 + }
50 + });
51 + for (var x = args[i]; i < len; x = args[++i]) {
52 + if (isNull(x) || !isObject(x)) {
53 + str += ' ' + x;
54 + } else {
55 + str += ' ' + inspect(x);
56 + }
57 + }
58 + return str;
59 +};
60 +
61 +
62 +// Mark that a method should not be used.
63 +// Returns a modified function which warns once by default.
64 +// If --no-deprecation is set, then it is a no-op.
65 +exports.deprecate = function(fn, msg) {
66 + // Allow for deprecating things in the process of starting up.
67 + if (isUndefined(global.process)) {
68 + return function() {
69 + return exports.deprecate(fn, msg).apply(this, arguments);
70 + };
71 + }
72 +
73 + if (process.noDeprecation === true) {
74 + return fn;
75 + }
76 +
77 + var warned = false;
78 + function deprecated() {
79 + if (!warned) {
80 + if (process.throwDeprecation) {
81 + throw new Error(msg);
82 + } else if (process.traceDeprecation) {
83 + console.trace(msg);
84 + } else {
85 + console.error(msg);
86 + }
87 + warned = true;
88 + }
89 + return fn.apply(this, arguments);
90 + }
91 +
92 + return deprecated;
93 +};
94 +
95 +
96 +var debugs = {};
97 +var debugEnviron;
98 +exports.debuglog = function(set) {
99 + if (isUndefined(debugEnviron))
100 + debugEnviron = process.env.NODE_DEBUG || '';
101 + set = set.toUpperCase();
102 + if (!debugs[set]) {
103 + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
104 + var pid = process.pid;
105 + debugs[set] = function() {
106 + var msg = exports.format.apply(exports, arguments);
107 + console.error('%s %d: %s', set, pid, msg);
108 + };
109 + } else {
110 + debugs[set] = function() {};
111 + }
112 + }
113 + return debugs[set];
114 +};
115 +
116 +
117 +/**
118 + * Echos the value of a value. Trys to print the value out
119 + * in the best way possible given the different types.
120 + *
121 + * @param {Object} obj The object to print out.
122 + * @param {Object} opts Optional options object that alters the output.
123 + */
124 +/* legacy: obj, showHidden, depth, colors*/
125 +function inspect(obj, opts) {
126 + // default options
127 + var ctx = {
128 + seen: [],
129 + stylize: stylizeNoColor
130 + };
131 + // legacy...
132 + if (arguments.length >= 3) ctx.depth = arguments[2];
133 + if (arguments.length >= 4) ctx.colors = arguments[3];
134 + if (isBoolean(opts)) {
135 + // legacy...
136 + ctx.showHidden = opts;
137 + } else if (opts) {
138 + // got an "options" object
139 + exports._extend(ctx, opts);
140 + }
141 + // set default options
142 + if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
143 + if (isUndefined(ctx.depth)) ctx.depth = 2;
144 + if (isUndefined(ctx.colors)) ctx.colors = false;
145 + if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
146 + if (ctx.colors) ctx.stylize = stylizeWithColor;
147 + return formatValue(ctx, obj, ctx.depth);
148 +}
149 +exports.inspect = inspect;
150 +
151 +
152 +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
153 +inspect.colors = {
154 + 'bold' : [1, 22],
155 + 'italic' : [3, 23],
156 + 'underline' : [4, 24],
157 + 'inverse' : [7, 27],
158 + 'white' : [37, 39],
159 + 'grey' : [90, 39],
160 + 'black' : [30, 39],
161 + 'blue' : [34, 39],
162 + 'cyan' : [36, 39],
163 + 'green' : [32, 39],
164 + 'magenta' : [35, 39],
165 + 'red' : [31, 39],
166 + 'yellow' : [33, 39]
167 +};
168 +
169 +// Don't use 'blue' not visible on cmd.exe
170 +inspect.styles = {
171 + 'special': 'cyan',
172 + 'number': 'yellow',
173 + 'boolean': 'yellow',
174 + 'undefined': 'grey',
175 + 'null': 'bold',
176 + 'string': 'green',
177 + 'date': 'magenta',
178 + // "name": intentionally not styling
179 + 'regexp': 'red'
180 +};
181 +
182 +
183 +function stylizeWithColor(str, styleType) {
184 + var style = inspect.styles[styleType];
185 +
186 + if (style) {
187 + return '\u001b[' + inspect.colors[style][0] + 'm' + str +
188 + '\u001b[' + inspect.colors[style][1] + 'm';
189 + } else {
190 + return str;
191 + }
192 +}
193 +
194 +
195 +function stylizeNoColor(str, styleType) {
196 + return str;
197 +}
198 +
199 +
200 +function arrayToHash(array) {
201 + var hash = {};
202 +
203 + array.forEach(function(val, idx) {
204 + hash[val] = true;
205 + });
206 +
207 + return hash;
208 +}
209 +
210 +
211 +function formatValue(ctx, value, recurseTimes) {
212 + // Provide a hook for user-specified inspect functions.
213 + // Check that value is an object with an inspect function on it
214 + if (ctx.customInspect &&
215 + value &&
216 + isFunction(value.inspect) &&
217 + // Filter out the util module, it's inspect function is special
218 + value.inspect !== exports.inspect &&
219 + // Also filter out any prototype objects using the circular check.
220 + !(value.constructor && value.constructor.prototype === value)) {
221 + var ret = value.inspect(recurseTimes, ctx);
222 + if (!isString(ret)) {
223 + ret = formatValue(ctx, ret, recurseTimes);
224 + }
225 + return ret;
226 + }
227 +
228 + // Primitive types cannot have properties
229 + var primitive = formatPrimitive(ctx, value);
230 + if (primitive) {
231 + return primitive;
232 + }
233 +
234 + // Look up the keys of the object.
235 + var keys = Object.keys(value);
236 + var visibleKeys = arrayToHash(keys);
237 +
238 + if (ctx.showHidden) {
239 + keys = Object.getOwnPropertyNames(value);
240 + }
241 +
242 + // IE doesn't make error fields non-enumerable
243 + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
244 + if (isError(value)
245 + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
246 + return formatError(value);
247 + }
248 +
249 + // Some type of object without properties can be shortcutted.
250 + if (keys.length === 0) {
251 + if (isFunction(value)) {
252 + var name = value.name ? ': ' + value.name : '';
253 + return ctx.stylize('[Function' + name + ']', 'special');
254 + }
255 + if (isRegExp(value)) {
256 + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
257 + }
258 + if (isDate(value)) {
259 + return ctx.stylize(Date.prototype.toString.call(value), 'date');
260 + }
261 + if (isError(value)) {
262 + return formatError(value);
263 + }
264 + }
265 +
266 + var base = '', array = false, braces = ['{', '}'];
267 +
268 + // Make Array say that they are Array
269 + if (isArray(value)) {
270 + array = true;
271 + braces = ['[', ']'];
272 + }
273 +
274 + // Make functions say that they are functions
275 + if (isFunction(value)) {
276 + var n = value.name ? ': ' + value.name : '';
277 + base = ' [Function' + n + ']';
278 + }
279 +
280 + // Make RegExps say that they are RegExps
281 + if (isRegExp(value)) {
282 + base = ' ' + RegExp.prototype.toString.call(value);
283 + }
284 +
285 + // Make dates with properties first say the date
286 + if (isDate(value)) {
287 + base = ' ' + Date.prototype.toUTCString.call(value);
288 + }
289 +
290 + // Make error with message first say the error
291 + if (isError(value)) {
292 + base = ' ' + formatError(value);
293 + }
294 +
295 + if (keys.length === 0 && (!array || value.length == 0)) {
296 + return braces[0] + base + braces[1];
297 + }
298 +
299 + if (recurseTimes < 0) {
300 + if (isRegExp(value)) {
301 + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
302 + } else {
303 + return ctx.stylize('[Object]', 'special');
304 + }
305 + }
306 +
307 + ctx.seen.push(value);
308 +
309 + var output;
310 + if (array) {
311 + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
312 + } else {
313 + output = keys.map(function(key) {
314 + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
315 + });
316 + }
317 +
318 + ctx.seen.pop();
319 +
320 + return reduceToSingleString(output, base, braces);
321 +}
322 +
323 +
324 +function formatPrimitive(ctx, value) {
325 + if (isUndefined(value))
326 + return ctx.stylize('undefined', 'undefined');
327 + if (isString(value)) {
328 + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
329 + .replace(/'/g, "\\'")
330 + .replace(/\\"/g, '"') + '\'';
331 + return ctx.stylize(simple, 'string');
332 + }
333 + if (isNumber(value))
334 + return ctx.stylize('' + value, 'number');
335 + if (isBoolean(value))
336 + return ctx.stylize('' + value, 'boolean');
337 + // For some reason typeof null is "object", so special case here.
338 + if (isNull(value))
339 + return ctx.stylize('null', 'null');
340 +}
341 +
342 +
343 +function formatError(value) {
344 + return '[' + Error.prototype.toString.call(value) + ']';
345 +}
346 +
347 +
348 +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
349 + var output = [];
350 + for (var i = 0, l = value.length; i < l; ++i) {
351 + if (hasOwnProperty(value, String(i))) {
352 + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
353 + String(i), true));
354 + } else {
355 + output.push('');
356 + }
357 + }
358 + keys.forEach(function(key) {
359 + if (!key.match(/^\d+$/)) {
360 + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
361 + key, true));
362 + }
363 + });
364 + return output;
365 +}
366 +
367 +
368 +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
369 + var name, str, desc;
370 + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
371 + if (desc.get) {
372 + if (desc.set) {
373 + str = ctx.stylize('[Getter/Setter]', 'special');
374 + } else {
375 + str = ctx.stylize('[Getter]', 'special');
376 + }
377 + } else {
378 + if (desc.set) {
379 + str = ctx.stylize('[Setter]', 'special');
380 + }
381 + }
382 + if (!hasOwnProperty(visibleKeys, key)) {
383 + name = '[' + key + ']';
384 + }
385 + if (!str) {
386 + if (ctx.seen.indexOf(desc.value) < 0) {
387 + if (isNull(recurseTimes)) {
388 + str = formatValue(ctx, desc.value, null);
389 + } else {
390 + str = formatValue(ctx, desc.value, recurseTimes - 1);
391 + }
392 + if (str.indexOf('\n') > -1) {
393 + if (array) {
394 + str = str.split('\n').map(function(line) {
395 + return ' ' + line;
396 + }).join('\n').substr(2);
397 + } else {
398 + str = '\n' + str.split('\n').map(function(line) {
399 + return ' ' + line;
400 + }).join('\n');
401 + }
402 + }
403 + } else {
404 + str = ctx.stylize('[Circular]', 'special');
405 + }
406 + }
407 + if (isUndefined(name)) {
408 + if (array && key.match(/^\d+$/)) {
409 + return str;
410 + }
411 + name = JSON.stringify('' + key);
412 + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
413 + name = name.substr(1, name.length - 2);
414 + name = ctx.stylize(name, 'name');
415 + } else {
416 + name = name.replace(/'/g, "\\'")
417 + .replace(/\\"/g, '"')
418 + .replace(/(^"|"$)/g, "'");
419 + name = ctx.stylize(name, 'string');
420 + }
421 + }
422 +
423 + return name + ': ' + str;
424 +}
425 +
426 +
427 +function reduceToSingleString(output, base, braces) {
428 + var numLinesEst = 0;
429 + var length = output.reduce(function(prev, cur) {
430 + numLinesEst++;
431 + if (cur.indexOf('\n') >= 0) numLinesEst++;
432 + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
433 + }, 0);
434 +
435 + if (length > 60) {
436 + return braces[0] +
437 + (base === '' ? '' : base + '\n ') +
438 + ' ' +
439 + output.join(',\n ') +
440 + ' ' +
441 + braces[1];
442 + }
443 +
444 + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
445 +}
446 +
447 +
448 +// NOTE: These type checking functions intentionally don't use `instanceof`
449 +// because it is fragile and can be easily faked with `Object.create()`.
450 +function isArray(ar) {
451 + return Array.isArray(ar);
452 +}
453 +exports.isArray = isArray;
454 +
455 +function isBoolean(arg) {
456 + return typeof arg === 'boolean';
457 +}
458 +exports.isBoolean = isBoolean;
459 +
460 +function isNull(arg) {
461 + return arg === null;
462 +}
463 +exports.isNull = isNull;
464 +
465 +function isNullOrUndefined(arg) {
466 + return arg == null;
467 +}
468 +exports.isNullOrUndefined = isNullOrUndefined;
469 +
470 +function isNumber(arg) {
471 + return typeof arg === 'number';
472 +}
473 +exports.isNumber = isNumber;
474 +
475 +function isString(arg) {
476 + return typeof arg === 'string';
477 +}
478 +exports.isString = isString;
479 +
480 +function isSymbol(arg) {
481 + return typeof arg === 'symbol';
482 +}
483 +exports.isSymbol = isSymbol;
484 +
485 +function isUndefined(arg) {
486 + return arg === void 0;
487 +}
488 +exports.isUndefined = isUndefined;
489 +
490 +function isRegExp(re) {
491 + return isObject(re) && objectToString(re) === '[object RegExp]';
492 +}
493 +exports.isRegExp = isRegExp;
494 +
495 +function isObject(arg) {
496 + return typeof arg === 'object' && arg !== null;
497 +}
498 +exports.isObject = isObject;
499 +
500 +function isDate(d) {
501 + return isObject(d) && objectToString(d) === '[object Date]';
502 +}
503 +exports.isDate = isDate;
504 +
505 +function isError(e) {
506 + return isObject(e) &&
507 + (objectToString(e) === '[object Error]' || e instanceof Error);
508 +}
509 +exports.isError = isError;
510 +
511 +function isFunction(arg) {
512 + return typeof arg === 'function';
513 +}
514 +exports.isFunction = isFunction;
515 +
516 +function isPrimitive(arg) {
517 + return arg === null ||
518 + typeof arg === 'boolean' ||
519 + typeof arg === 'number' ||
520 + typeof arg === 'string' ||
521 + typeof arg === 'symbol' || // ES6 symbol
522 + typeof arg === 'undefined';
523 +}
524 +exports.isPrimitive = isPrimitive;
525 +
526 +exports.isBuffer = require('./support/isBuffer');
527 +
528 +function objectToString(o) {
529 + return Object.prototype.toString.call(o);
530 +}
531 +
532 +
533 +function pad(n) {
534 + return n < 10 ? '0' + n.toString(10) : n.toString(10);
535 +}
536 +
537 +
538 +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
539 + 'Oct', 'Nov', 'Dec'];
540 +
541 +// 26 Feb 16:19:34
542 +function timestamp() {
543 + var d = new Date();
544 + var time = [pad(d.getHours()),
545 + pad(d.getMinutes()),
546 + pad(d.getSeconds())].join(':');
547 + return [d.getDate(), months[d.getMonth()], time].join(' ');
548 +}
549 +
550 +
551 +// log is just a thin wrapper to console.log that prepends a timestamp
552 +exports.log = function() {
553 + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
554 +};
555 +
556 +
557 +/**
558 + * Inherit the prototype methods from one constructor into another.
559 + *
560 + * The Function.prototype.inherits from lang.js rewritten as a standalone
561 + * function (not on Function.prototype). NOTE: If this file is to be loaded
562 + * during bootstrapping this function needs to be rewritten using some native
563 + * functions as prototype setup using normal JavaScript does not work as
564 + * expected during bootstrapping (see mirror.js in r114903).
565 + *
566 + * @param {function} ctor Constructor function which needs to inherit the
567 + * prototype.
568 + * @param {function} superCtor Constructor function to inherit prototype from.
569 + */
570 +exports.inherits = require('inherits');
571 +
572 +exports._extend = function(origin, add) {
573 + // Don't do anything if add isn't an object
574 + if (!add || !isObject(add)) return origin;
575 +
576 + var keys = Object.keys(add);
577 + var i = keys.length;
578 + while (i--) {
579 + origin[keys[i]] = add[keys[i]];
580 + }
581 + return origin;
582 +};
583 +
584 +function hasOwnProperty(obj, prop) {
585 + return Object.prototype.hasOwnProperty.call(obj, prop);
586 +}
...@@ -585,6 +585,15 @@ ...@@ -585,6 +585,15 @@
585 "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 585 "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
586 "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" 586 "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
587 }, 587 },
588 + "path": {
589 + "version": "0.12.7",
590 + "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
591 + "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=",
592 + "requires": {
593 + "process": "^0.11.1",
594 + "util": "^0.10.3"
595 + }
596 + },
588 "path-parse": { 597 "path-parse": {
589 "version": "1.0.6", 598 "version": "1.0.6",
590 "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", 599 "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
...@@ -595,6 +604,11 @@ ...@@ -595,6 +604,11 @@
595 "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 604 "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
596 "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 605 "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
597 }, 606 },
607 + "process": {
608 + "version": "0.11.10",
609 + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
610 + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI="
611 + },
598 "process-nextick-args": { 612 "process-nextick-args": {
599 "version": "2.0.1", 613 "version": "2.0.1",
600 "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", 614 "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
...@@ -911,14 +925,21 @@ ...@@ -911,14 +925,21 @@
911 "uglify-to-browserify": { 925 "uglify-to-browserify": {
912 "version": "1.0.2", 926 "version": "1.0.2",
913 "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", 927 "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz",
914 - "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", 928 + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc="
915 - "optional": true
916 }, 929 },
917 "unpipe": { 930 "unpipe": {
918 "version": "1.0.0", 931 "version": "1.0.0",
919 "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 932 "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
920 "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 933 "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
921 }, 934 },
935 + "util": {
936 + "version": "0.10.4",
937 + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
938 + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
939 + "requires": {
940 + "inherits": "2.0.3"
941 + }
942 + },
922 "util-deprecate": { 943 "util-deprecate": {
923 "version": "1.0.2", 944 "version": "1.0.2",
924 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 945 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
......
...@@ -2,8 +2,24 @@ ...@@ -2,8 +2,24 @@
2 2
3 const express = require('express'); 3 const express = require('express');
4 const multer = require('multer'); 4 const multer = require('multer');
5 +
6 +var storage = multer.diskStorage({
7 + destination: function (req, file, cb) {
8 + var dir = req.params.directoryName;
9 + cb(null, './tensorflow/data/' + dir + '/');
10 + },
11 + filename: function (req, file, cb) {
12 + cb(null, new Date().valueOf() + "_" + file.originalname);
13 + }
14 +});
15 +
16 +var upload = multer({
17 + storage: storage
18 +});
19 +
5 const bodyParser = require('body-parser'); 20 const bodyParser = require('body-parser');
6 const fs = require('fs'); 21 const fs = require('fs');
22 +const path = require('path');
7 23
8 const PORT = 8080; 24 const PORT = 8080;
9 const HOST = '0.0.0.0'; 25 const HOST = '0.0.0.0';
...@@ -23,12 +39,12 @@ app.use(bodyParser.urlencoded({extended:false})); ...@@ -23,12 +39,12 @@ app.use(bodyParser.urlencoded({extended:false}));
23 39
24 // Redirect Root to Home 40 // Redirect Root to Home
25 app.get('/', (req, res) => { 41 app.get('/', (req, res) => {
26 - res.redirect('/home'); 42 + res.redirect('./home/');
27 }); 43 });
28 44
29 45
30 // Main Page 46 // Main Page
31 -app.get('/home', (req, res) => { 47 +app.get('/home/', (req, res) => {
32 fs.readdir(dataFolder, function(error, filelist){ 48 fs.readdir(dataFolder, function(error, filelist){
33 if(error) 49 if(error)
34 console.log(error); 50 console.log(error);
...@@ -53,45 +69,50 @@ app.post('/directory_check', (req, res) => { ...@@ -53,45 +69,50 @@ app.post('/directory_check', (req, res) => {
53 { 69 {
54 // Make directory 70 // Make directory
55 fs.mkdirSync(dataFolder + '/' + dir); 71 fs.mkdirSync(dataFolder + '/' + dir);
56 - console.log('디렉토리: ' + dir + ' 생성 완료'); 72 + console.log('Directory Create: ' + dir);
57 - res.redirect('/home/' + dir); 73 + res.redirect('/home/' + dir + '/');
58 } 74 }
59 }); 75 });
60 76
61 77
62 // Basic Directory Page 78 // Basic Directory Page
63 -app.get('/home/:directoryName', (req, res) => { 79 +app.get('/home/:directoryName/', (req, res) => {
64 - 80 + // 아래 주석 처리된 코드는 화면에서 이미지를 보여주기 위한 코드
81 + // 그러나 client에게 이미지를 보여주기 위해서는 Amazon S3를 이용해야 함
82 + // 아직 Amazon S3 기능을 추가하지 못함
83 + // var directoryName = new String(req.params.directoryName);
84 + // var ImageList = new Array();
85 + // var Path = dataFolder + '/' + directoryName;
86 + // fs.readdirSync(Path).forEach(function(file,index){
87 + // var fileType = path.extname(file);
88 + // if(fileType == ".jpg" || fileType == ".jpeg") {
89 + // ImageList.push("." + Path + "/" + file);
90 + // }
91 + // });
92 + // res.render('directory', {FileList:ImageList});
93 + var directoryName = req.params.directoryName;
94 + res.render('directory', {directoryName:directoryName});
65 }); 95 });
66 96
67 97
68 // Image Upload Directory Page 98 // Image Upload Directory Page
69 -app.get('/home/:directoryName/upload', (req, res) => { 99 +app.post('/home/:directoryName/upload/', upload.array('userImage'), (req, res) => {
70 - var upload_data = multer({ dest: 'tensorflow/data/' + directoryName }); 100 + var directoryName = req.params.directoryName;
71 - upload_data.array('ImageData')
72 var imgFileArr = req.files; 101 var imgFileArr = req.files;
102 + console.log("files: " + req.files);
103 + res.redirect('/home/' + directoryName + '/');
73 }); 104 });
74 105
75 106
76 // Modify Directory name 107 // Modify Directory name
77 -app.get('/home/:directoryName/modify', (req, res) => { 108 +app.get('/home/:directoryName/modify/', (req, res) => {
78 // exist query.newName 109 // exist query.newName
79 - var directoryName = new String(req.params.directoryName); 110 + var directoryName = req.params.directoryName;
80 - var newName = new String(req.query.newName); 111 + var newName = req.query.newName;
81 if (req.query.newName) { 112 if (req.query.newName) {
82 - // modify Directory name and Files 113 + // modify Directory name
83 - var path = dataFolder + '/' + directoryName; 114 + var Path = dataFolder + '/' + directoryName;
84 - fs.readdirSync(path).forEach(function(file,index){ 115 + fs.rename(Path, dataFolder + '/' + newName, function (err) {
85 - var curPath = path + "/" + file;
86 - var fileNameArr = string.split("_");
87 - var newPath = path + "/" + newName + "_" + fileNameArr[1];
88 - fs.rename(curPath, newPath, function (err) {
89 - if (err) {
90 - console.log("File Rename error: " + err);
91 - }
92 - });
93 - });
94 - fs.rename(path, dataFolder + '/' + newName, function (err) {
95 if (err) { 116 if (err) {
96 console.log("Directory Rename error: " + err); 117 console.log("Directory Rename error: " + err);
97 } else { 118 } else {
...@@ -107,9 +128,9 @@ app.get('/home/:directoryName/modify', (req, res) => { ...@@ -107,9 +128,9 @@ app.get('/home/:directoryName/modify', (req, res) => {
107 128
108 129
109 // Delete Directory 130 // Delete Directory
110 -app.get('/home/:directoryName/delete', (req, res) => { 131 +app.get('/home/:directoryName/delete/', (req, res) => {
111 // exist query.real 132 // exist query.real
112 - var directoryName = new String(req.params.directoryName); 133 + var directoryName = req.params.directoryName;
113 if (req.query.real) { 134 if (req.query.real) {
114 // Remove Directory and Files 135 // Remove Directory and Files
115 var path = dataFolder + '/' + directoryName; 136 var path = dataFolder + '/' + directoryName;
...@@ -118,6 +139,7 @@ app.get('/home/:directoryName/delete', (req, res) => { ...@@ -118,6 +139,7 @@ app.get('/home/:directoryName/delete', (req, res) => {
118 fs.unlinkSync(curPath); 139 fs.unlinkSync(curPath);
119 }); 140 });
120 fs.rmdirSync(path); 141 fs.rmdirSync(path);
142 + console.log('Directory Delete: ' + dir);
121 res.redirect('/'); 143 res.redirect('/');
122 } 144 }
123 else { 145 else {
......
...@@ -3,7 +3,27 @@ html ...@@ -3,7 +3,27 @@ html
3 head 3 head
4 meta(charset='utf-8') 4 meta(charset='utf-8')
5 title 파일 업로드 5 title 파일 업로드
6 +
7 + style
8 + img
9 + | display="block"
10 + | max-width="200px"
11 + | max-height="200px"
12 + | width="auto"
13 + | height="auto"
14 +
15 +
6 body 16 body
7 - form(action="upload" method="POST" enctype="multipart/form-data")
8 - input(type="file", name="userfile[]", multiple="multiple")
9 - input(type="submit", value="전송")
...\ No newline at end of file ...\ No newline at end of file
17 + - var DirectoryName=directoryName;
18 + h1=DirectoryName
19 + h2 파일 업로드
20 + br
21 + br
22 + form(action="./upload/" method="POST" enctype="multipart/form-data")
23 + input(type="file", name="userImage", multiple="multiple", accept=".jpg, .jpeg")
24 + input(type="submit", value="업로드")
25 + br
26 + //- var ImageList=FileList
27 + each Image in ImageList
28 + div(style="margin-right:10px; float:left;")
29 + img(src=Image)
...\ No newline at end of file ...\ No newline at end of file
......
1 script. 1 script.
2 var directoryName= !{directoryName}; 2 var directoryName= !{directoryName};
3 confirm('모든 이미지가 삭제됩니다.\n정말 ' + directoryName + ' 분류를 삭제하시겠습니까?') 3 confirm('모든 이미지가 삭제됩니다.\n정말 ' + directoryName + ' 분류를 삭제하시겠습니까?')
4 - ? location.href = location + 'real=true' : history.back();
...\ No newline at end of file ...\ No newline at end of file
4 + ? location.href ='.?real=true' : history.back();
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,7 +3,7 @@ script. ...@@ -3,7 +3,7 @@ script.
3 var result = prompt('새 분류명을 입력하세요. (기존: ' + directoryName + ')'); 3 var result = prompt('새 분류명을 입력하세요. (기존: ' + directoryName + ')');
4 4
5 if (result) { 5 if (result) {
6 - location.href = location + 'newName=' + result; 6 + location.href = '.?newName=' + result;
7 } else { 7 } else {
8 alert('분류명을 수정하지 않습니다.'); 8 alert('분류명을 수정하지 않습니다.');
9 history.back(); 9 history.back();
......
1 -<script type="text/javascript">
2 -alert("이미 존재하는 분류입니다.");
3 -history.back();
4 -</script>
...@@ -7,14 +7,14 @@ html ...@@ -7,14 +7,14 @@ html
7 7
8 8
9 body 9 body
10 - form(action="directory_check" method="post") 10 + form(action="../directory_check" method="post")
11 p 새로 만들 분류명: 11 p 새로 만들 분류명:
12 input(name="directoryName", type="text") 12 input(name="directoryName", type="text")
13 input(type="submit", value="생성") 13 input(type="submit", value="생성")
14 br 14 br
15 15
16 16
17 - form(action="test" method="post" enctype="multipart/form-data") 17 + form(action="../test" method="post" enctype="multipart/form-data")
18 p 테스트할 이미지: 18 p 테스트할 이미지:
19 input(name="ImageTest", type="file") 19 input(name="ImageTest", type="file")
20 input(type="submit", value="테스트") 20 input(type="submit", value="테스트")
...@@ -26,13 +26,13 @@ html ...@@ -26,13 +26,13 @@ html
26 each folder in folderList 26 each folder in folderList
27 div(style="margin-right:30px; float:left;") 27 div(style="margin-right:30px; float:left;")
28 li 28 li
29 - a(href=location+folder)=folder 29 + a(href="./"+folder+"/")=folder
30 30
31 div(style="margin-right:5px; float:left;") 31 div(style="margin-right:5px; float:left;")
32 - form(action="home/"+folder+"/modify" method="get") 32 + form(action="./"+folder+"/modify/" method="get")
33 input(type="submit", value="수정") 33 input(type="submit", value="수정")
34 34
35 div 35 div
36 - form(action="home/"+folder+"/delete" method="get") 36 + form(action="./"+folder+"/delete/" method="get")
37 input(type="submit", value="삭제") 37 input(type="submit", value="삭제")
38 br 38 br
...\ No newline at end of file ...\ No newline at end of file
......