Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: base/android/java/src/org/chromium/base/ApkAssets.java

Issue 1424983004: Using copy_ex to copy assets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: using copy_ex Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/gyp/copy_ex.py » ('j') | build/android/gyp/copy_ex.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.base; 5 package org.chromium.base;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.res.AssetFileDescriptor; 8 import android.content.res.AssetFileDescriptor;
9 import android.content.res.AssetManager; 9 import android.content.res.AssetManager;
10 import android.util.Log; 10 import android.util.Log;
(...skipping 15 matching lines...) Expand all
26 @CalledByNative 26 @CalledByNative
27 public static long[] open(Context context, String fileName) { 27 public static long[] open(Context context, String fileName) {
28 AssetFileDescriptor afd = null; 28 AssetFileDescriptor afd = null;
29 try { 29 try {
30 AssetManager manager = context.getAssets(); 30 AssetManager manager = context.getAssets();
31 afd = manager.openNonAssetFd(fileName); 31 afd = manager.openNonAssetFd(fileName);
32 return new long[] { afd.getParcelFileDescriptor().detachFd(), 32 return new long[] { afd.getParcelFileDescriptor().detachFd(),
33 afd.getStartOffset(), 33 afd.getStartOffset(),
34 afd.getLength() }; 34 afd.getLength() };
35 } catch (IOException e) { 35 } catch (IOException e) {
36 // TODO(michaelbai): Remove dump assets once crbug.com/547235 fixed.
37 try {
38 String[] assets = context.getAssets().list("");
39 StringBuffer sb = new StringBuffer("Dump assets(" + assets.lengt h + "):\n");
40 for (String asset : assets) {
41 sb.append(asset);
42 sb.append("\n");
43 }
44 Log.e(LOGTAG, sb.toString());
45 } catch (IOException ioe) {
46 Log.e(LOGTAG, "Error while list assets: " + ioe);
47 }
48
36 Log.e(LOGTAG, "Error while loading asset " + fileName + ": " + e); 49 Log.e(LOGTAG, "Error while loading asset " + fileName + ": " + e);
37 return new long[] {-1, -1, -1}; 50 return new long[] {-1, -1, -1};
38 } finally { 51 } finally {
39 try { 52 try {
40 if (afd != null) { 53 if (afd != null) {
41 afd.close(); 54 afd.close();
42 } 55 }
43 } catch (IOException e2) { 56 } catch (IOException e2) {
44 Log.e(LOGTAG, "Unable to close AssetFileDescriptor", e2); 57 Log.e(LOGTAG, "Unable to close AssetFileDescriptor", e2);
45 } 58 }
46 } 59 }
47 } 60 }
48 } 61 }
OLDNEW
« no previous file with comments | « no previous file | build/android/gyp/copy_ex.py » ('j') | build/android/gyp/copy_ex.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698