file.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var dsa = DS.attr;
  20. App.File = DS.Model.extend({
  21. path: function() {
  22. return this.get('id');
  23. }.property('id'),
  24. basedir:function () {
  25. var path = this.get('id');
  26. return path.substring(0,path.lastIndexOf('/'))||'/';
  27. }.property('id'),
  28. isDirectory: dsa('boolean'),
  29. readAccess: dsa('boolean'),
  30. writeAccess: dsa('boolean'),
  31. executeAccess: dsa('boolean'),
  32. len: dsa('number'),
  33. owner: dsa('string'),
  34. group: dsa('string'),
  35. permission: dsa('string'),
  36. accessTime: dsa('isodate'),
  37. modificationTime: dsa('isodate'),
  38. blockSize: dsa('number'),
  39. replication: dsa('number'),
  40. name:function () {
  41. var splitpath = this.get('path').split('/');
  42. return splitpath.get(splitpath.length-1);
  43. }.property('path'),
  44. date:function () {
  45. return parseInt(moment(this.get('modificationTime')).format('X'))
  46. }.property('modificationTime'),
  47. size: Em.computed.alias('len')
  48. });