Browse files

Remove ancient, unused lib/resource dir

  • Loading branch information...
1 parent cd5a2fa commit ff30f3937c127702b1091f942ddccf375b7156ab @mamacdon committed Dec 11, 2012
Showing with 0 additions and 75 deletions.
  1. +0 −46 lib/resource/dirOld.js
  2. +0 −29 lib/resource/fileOld.js
View
46 lib/resource/dirOld.js
@@ -1,46 +0,0 @@
-/*global exports require*/
-var ct = require('../contenttype').makeHeader;
-var fs = require('promised-io/fs');
-var PromisedIO = require('promised-io');
-var path = require('path');
-
-function DirectoryListResource(dirpath, location, stats) {
- this.path = path;
- var dir = this.dir = {};
- dir.Name = path.basename(dirpath);
- dir.Location = location;
- dir.LocalTimeStamp = stats.mtime.getTime();
- // this.promise resolves with dir data when children have been gotten
- this.promise = fs.readdir(dirpath).then(function(files) {
- // stat each file to get its 'Directory' -- ugh
- var childStatPromises = files.map(function(file) {
- var filepath = path.join(dirpath, file);
- return fs.stat(filepath).then(function(stat) {
- return [filepath, stat];
- });
- });
- return PromisedIO.all(childStatPromises).then(function(childStats) {
- dir.Children = childStats.map(function(cs) {
- var childname = path.basename(cs[0]);
- return {
- Name: childname,
- Directory: cs[1].isDirectory(),
- Location: (location + '/' + childname)
- };
- });
- return dir; // resolve our promise, yay
- });
- });
-}
-DirectoryListResource.prototype.write = function(resp) {
- return this.promise.then(function(dir) {
- resp.writeHead(200, ct('json'));
- resp.write(JSON.stringify(dir));
- resp.end();
- }, function(e) {
- resp.writeHead(500);
- resp.write(e.toString());
- resp.end();
- });
-};
-exports.DirectoryListResource = DirectoryListResource;
View
29 lib/resource/fileOld.js
@@ -1,29 +0,0 @@
-/*global require exports*/
-var ct = require('../contenttype').makeHeader;
-
-function FileDataResource(data) {
- this.data = data;
-}
-FileDataResource.prototype.write = function(resp) {
- resp.writeHead(200);
- resp.write(this.data);
- resp.end();
-};
-
-function FileMetadataResource(name, location, stats) {
- var meta = this.metadata = {};
- meta.Directory = false;
- // TODO
- //meta.ETag
- meta.Name = name;
- meta.Location = location;
- meta.LocalTimeStamp = stats.mtime.getTime();
-}
-FileMetadataResource.prototype.write = function(resp) {
- resp.writeHead(200, ct('json'));
- resp.write(JSON.stringify(this.metadata));
- resp.end();
-};
-
-exports.FileDataResource = FileDataResource;
-exports.FileMetadataResource = FileMetadataResource;

0 comments on commit ff30f39

Please sign in to comment.