3
0

APKHandler.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. package com.amazon.lumberyard.io;
  9. import android.content.res.AssetManager;
  10. import android.util.Log;
  11. import java.io.IOException;
  12. import android.app.Activity;
  13. ////////////////////////////////////////////////////////////////
  14. public class APKHandler
  15. {
  16. ////////////////////////////////////////////////////////////////
  17. public static void SetAssetManager(AssetManager assetManager)
  18. {
  19. s_assetManager = assetManager;
  20. }
  21. ////////////////////////////////////////////////////////////////
  22. public static String[] GetFilesAndDirectoriesInPath(String path)
  23. {
  24. String[] filelist = {};
  25. try
  26. {
  27. filelist = s_assetManager.list(path);
  28. }
  29. catch (IOException e)
  30. {
  31. Log.e(s_tag, String.format("File I/O error: %s", e.getMessage()));
  32. e.printStackTrace();
  33. }
  34. finally
  35. {
  36. if (s_debug)
  37. {
  38. Log.d(s_tag, String.format("Files in path: %s", path));
  39. for(String name : filelist)
  40. {
  41. Log.d(s_tag, String.format(" -- %s", name));
  42. }
  43. }
  44. return filelist;
  45. }
  46. }
  47. ////////////////////////////////////////////////////////////////
  48. public static boolean IsDirectory(String path)
  49. {
  50. String[] filelist = {};
  51. boolean retVal = false;
  52. try
  53. {
  54. filelist = s_assetManager.list(path);
  55. if(filelist.length > 0)
  56. {
  57. retVal = true;
  58. }
  59. }
  60. catch (IOException e)
  61. {
  62. Log.e(s_tag, String.format("File I/O error: %s", e.getMessage()));
  63. e.printStackTrace();
  64. }
  65. finally
  66. {
  67. return retVal;
  68. }
  69. }
  70. // ----
  71. private static final String s_tag = "LMBR";
  72. private static AssetManager s_assetManager = null;
  73. private static boolean s_debug = false;
  74. }