1 /* 2 * Copyright (C) 2010 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 package com.android.tradefed.device; 17 18 import com.android.ddmlib.FileListingService; 19 import com.android.ddmlib.FileListingService.FileEntry; 20 21 import java.util.Collection; 22 23 /** 24 * Interface definition that provides simpler, mockable contract to 25 * {@link FileEntry} methods. 26 * <p/> 27 * TODO: move this into ddmlib 28 */ 29 public interface IFileEntry { 30 31 /** 32 * Wrapper for {@link FileEntry#getFullEscapedPath()}. 33 */ getFullEscapedPath()34 public String getFullEscapedPath(); 35 36 /** 37 * Wrapper for {@link FileEntry#getFullPath()}. 38 */ getFullPath()39 public String getFullPath(); 40 41 /** 42 * Wrapper for {@link FileEntry#isDirectory()}. 43 */ isDirectory()44 public boolean isDirectory(); 45 46 /** 47 * Finds a child {@link IFileEntry} with given name. 48 * <p/> 49 * Basically a wrapper for {@link FileEntry#findChild(String)} that 50 * will also first search the cached children for file with given name, and if not found, 51 * refresh the cached child file list and attempt again. 52 * 53 * @throws DeviceNotAvailableException 54 */ findChild(String name)55 public IFileEntry findChild(String name) throws DeviceNotAvailableException; 56 57 /** 58 * Wrapper for {@link FileEntry#isAppFileName()}. 59 */ isAppFileName()60 public boolean isAppFileName(); 61 62 /** 63 * Wrapper for {@link FileEntry#getName()}. 64 */ getName()65 public String getName(); 66 67 /** 68 * Wrapper for {@link FileEntry#getTime()}. 69 */ getTime()70 public String getTime(); 71 72 /** 73 * Wrapper for {@link FileEntry#getDate()}. 74 */ getDate()75 public String getDate(); 76 77 /** 78 * Wrapper for {@link FileEntry#getPermissions()}. 79 */ getPermissions()80 public String getPermissions(); 81 82 /** 83 * Returns the children of a {@link IFileEntry}. 84 * <p/> 85 * Basically a synchronous wrapper for 86 * {@link FileListingService#getChildren(FileEntry, boolean, FileListingService.IListingReceiver)} 87 * 88 * @param useCache <code>true</code> if the cached children should be returned if available. 89 * <code>false</code> if a new ls command should be forced. 90 * @return list of sub files 91 * @throws DeviceNotAvailableException 92 */ getChildren(boolean useCache)93 public Collection<IFileEntry> getChildren(boolean useCache) throws DeviceNotAvailableException; 94 95 /** 96 * Return reference to the ddmlib {@link FileEntry}. 97 */ getFileEntry()98 public FileEntry getFileEntry(); 99 100 } 101