1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16export enum FileType { 17 FOLDER = 'folder', 18 IMAGE = 'image', 19 Video = 'video', 20 MUSIC = 'music', 21 DOCUMENT = 'document' 22} 23 24export class FileModel { 25 name: string; 26 isFolder: boolean; 27 fileType: string; 28 files: Array<string>; 29 30 constructor(name: string, isFolder: boolean, files: Array<string>) { 31 this.name = name; 32 this.files = files; 33 this.isFolder = isFolder; 34 if (isFolder) { 35 this.fileType = FileType.FOLDER 36 } else { 37 if (this.name.endsWith('.mp4')) { 38 this.fileType = FileType.Video 39 } else if (this.name.endsWith('.mp3')) { 40 this.fileType = FileType.MUSIC 41 } else if (this.name.endsWith('.jpg') || this.name.endsWith('.png') || this.name.endsWith('.jpeg')) { 42 this.fileType = FileType.IMAGE 43 } else { 44 this.fileType = FileType.DOCUMENT 45 } 46 } 47 } 48}