Home | History | Annotate | Download | only in shadows
      1 package org.robolectric.shadows;
      2 
      3 import android.os.Build;
      4 import android.system.ErrnoException;
      5 import android.system.StructStat;
      6 import java.io.File;
      7 import org.robolectric.RuntimeEnvironment;
      8 import org.robolectric.annotation.Implementation;
      9 import org.robolectric.annotation.Implements;
     10 import org.robolectric.util.ReflectionHelpers;
     11 
     12 @Implements(className = "libcore.io.Posix", maxSdk = Build.VERSION_CODES.N_MR1, isInAndroidSdk = false)
     13 public class ShadowPosix {
     14   @Implementation
     15   public static void mkdir(String path, int mode) throws ErrnoException {
     16     new File(path).mkdirs();
     17   }
     18 
     19   @Implementation
     20   public static Object stat(String path) throws ErrnoException {
     21     if (RuntimeEnvironment.getApiLevel() >= Build.VERSION_CODES.LOLLIPOP) {
     22       return new StructStat(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
     23     } else {
     24       return ReflectionHelpers.newInstance(ReflectionHelpers.loadClass(ShadowPosix.class.getClassLoader(), "libcore.io.StructStat"));
     25     }
     26   }
     27 }
     28