1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.ide.common.resources.deprecated;
18 
19 import com.android.io.FolderWrapper;
20 import com.android.io.IAbstractResource;
21 
22 import java.io.File;
23 
24 public class TestFolderWrapper extends FolderWrapper {
25 
TestFolderWrapper(String pathname)26     public TestFolderWrapper(String pathname) {
27         super(pathname);
28     }
29 
TestFolderWrapper(File file)30     public TestFolderWrapper(File file) {
31         super(file.getAbsolutePath());
32     }
33 
listMembers()34     public IAbstractResource[] listMembers() {
35         File[] files = listFiles();
36         final int count = files == null ? 0 : files.length;
37         IAbstractResource[] afiles = new IAbstractResource[count];
38 
39         if (files != null) {
40             for (int i = 0 ; i < count ; i++) {
41                 File f = files[i];
42                 if (f.isFile()) {
43                     afiles[i] = new TestFileWrapper(f);
44                 } else if (f.isDirectory()) {
45                     afiles[i] = new TestFolderWrapper(f);
46                 }
47             }
48         }
49 
50         return afiles;
51     }
52 
getFolder(String name)53     public TestFolderWrapper getFolder(String name) {
54         return new TestFolderWrapper(new File(this, name));
55     }
56 }
57