dx.java 4.07 KB
import android.net.Uri;
import android.support.v4.provider.DocumentFile;
import android.util.Log;
import android.webkit.MimeTypeMap;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

public final class dx
  extends DocumentFile
{
  private File a;
  
  public dx(DocumentFile paramDocumentFile, File paramFile)
  {
    super(paramDocumentFile);
    this.a = paramFile;
  }
  
  private static boolean a(File paramFile)
  {
    paramFile = paramFile.listFiles();
    boolean bool2 = true;
    boolean bool1 = true;
    if (paramFile != null)
    {
      int j = paramFile.length;
      int i = 0;
      for (;;)
      {
        bool2 = bool1;
        if (i >= j) {
          break;
        }
        File localFile = paramFile[i];
        bool2 = bool1;
        if (localFile.isDirectory()) {
          bool2 = bool1 & a(localFile);
        }
        bool1 = bool2;
        if (!localFile.delete())
        {
          Log.w("DocumentFile", "Failed to delete " + localFile);
          bool1 = false;
        }
        i += 1;
      }
    }
    return bool2;
  }
  
  public final boolean canRead()
  {
    return this.a.canRead();
  }
  
  public final boolean canWrite()
  {
    return this.a.canWrite();
  }
  
  public final DocumentFile createDirectory(String paramString)
  {
    paramString = new File(this.a, paramString);
    if ((paramString.isDirectory()) || (paramString.mkdir())) {
      return new dx(this, paramString);
    }
    return null;
  }
  
  public final DocumentFile createFile(String paramString1, String paramString2)
  {
    String str = MimeTypeMap.getSingleton().getExtensionFromMimeType(paramString1);
    paramString1 = paramString2;
    if (str != null) {
      paramString1 = paramString2 + "." + str;
    }
    paramString1 = new File(this.a, paramString1);
    try
    {
      paramString1.createNewFile();
      paramString1 = new dx(this, paramString1);
      return paramString1;
    }
    catch (IOException paramString1)
    {
      Log.w("DocumentFile", "Failed to createFile: " + paramString1);
    }
    return null;
  }
  
  public final boolean delete()
  {
    a(this.a);
    return this.a.delete();
  }
  
  public final boolean exists()
  {
    return this.a.exists();
  }
  
  public final String getName()
  {
    return this.a.getName();
  }
  
  public final String getType()
  {
    Object localObject;
    if (this.a.isDirectory()) {
      localObject = null;
    }
    String str;
    do
    {
      return (String)localObject;
      localObject = this.a.getName();
      int i = ((String)localObject).lastIndexOf('.');
      if (i < 0) {
        break;
      }
      localObject = ((String)localObject).substring(i + 1).toLowerCase();
      str = MimeTypeMap.getSingleton().getMimeTypeFromExtension((String)localObject);
      localObject = str;
    } while (str != null);
    return "application/octet-stream";
  }
  
  public final Uri getUri()
  {
    return Uri.fromFile(this.a);
  }
  
  public final boolean isDirectory()
  {
    return this.a.isDirectory();
  }
  
  public final boolean isFile()
  {
    return this.a.isFile();
  }
  
  public final boolean isVirtual()
  {
    return false;
  }
  
  public final long lastModified()
  {
    return this.a.lastModified();
  }
  
  public final long length()
  {
    return this.a.length();
  }
  
  public final DocumentFile[] listFiles()
  {
    ArrayList localArrayList = new ArrayList();
    File[] arrayOfFile = this.a.listFiles();
    if (arrayOfFile != null)
    {
      int j = arrayOfFile.length;
      int i = 0;
      while (i < j)
      {
        localArrayList.add(new dx(this, arrayOfFile[i]));
        i += 1;
      }
    }
    return (DocumentFile[])localArrayList.toArray(new DocumentFile[localArrayList.size()]);
  }
  
  public final boolean renameTo(String paramString)
  {
    paramString = new File(this.a.getParentFile(), paramString);
    if (this.a.renameTo(paramString))
    {
      this.a = paramString;
      return true;
    }
    return false;
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/dx.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */