Lines Matching refs:file

5  * you may not use this file except in compliance with the License.
124 final File file = new File(getContext().getCacheDir(), rootId);
125 if (file.mkdir()) {
126 Log.i(TAG, "Created new root directory @ " + file.getPath());
128 final RootInfo rootInfo = new RootInfo(file, getSize(rootId));
169 final StubDocument file = mStorage.get(documentId);
170 if (file == null) {
173 includeDocument(result, file);
181 return FileUtils.contains(parentDocument.file, childDocument.file);
188 File file = createFile(parent, mimeType, displayName);
190 final StubDocument document = StubDocument.createRegularDocument(file, mimeType, parent);
205 final long fileSize = document.file.length();
206 if (document == null || !document.file.delete())
229 if (parentDocument == null || parentDocument.file.isFile()) {
237 for (File file : parentDocument.file.listFiles()) {
238 document = mStorage.get(getDocumentIdForFile(file));
259 if (parentDocument == null || parentDocument.file.isFile()) {
266 for (File file : parentDocument.file.listFiles()) {
267 if (file.getName().toLowerCase().contains(query)) {
268 StubDocument document = mStorage.get(getDocumentIdForFile(file));
283 File before = oldDoc.file;
321 if (document == null || !document.file.isFile()) {
325 throw new IllegalStateException("Tried to open a virtual file.");
332 document.file, ParcelFileDescriptor.MODE_WRITE_ONLY);
334 return ParcelFileDescriptor.open(document.file, ParcelFileDescriptor.MODE_READ_ONLY);
363 if (document == null || !document.file.isFile() || document.streamTypes == null) {
371 document.file, ParcelFileDescriptor.MODE_READ_ONLY);
380 return new AssetFileDescriptor(pfd, 0, document.file.length());
391 "The provided Uri is incorrect, or the file is gone.");
420 Log.d(TAG, "Opening write stream on file " + document.documentId);
422 outputStream = new FileOutputStream(document.file);
449 Log.d(TAG, "Closing write stream on file " + document.documentId);
511 Log.e(TAG, "Couldn't create virtual file.");
540 File file = createFile(parent, mimeType, displayName);
542 final StubDocument document = StubDocument.createDocumentWithFlags(file, mimeType, parent,
558 "Can't create file " + displayName + " in null parent.");
560 if (!parent.file.isDirectory()) {
562 "Can't create file " + displayName + " inside non-directory parent "
563 + parent.file.getName());
566 final File file = new File(parent.file, displayName);
567 if (file.exists()) {
569 "Duplicate file names not supported for " + file);
573 if (!file.mkdirs()) {
574 throw new FileNotFoundException("Failed to create directory(s): " + file);
576 Log.i(TAG, "Created new directory: " + file);
580 created = file.createNewFile();
583 Log.e(TAG, "createNewFile operation failed for file: " + file, e);
586 throw new FileNotFoundException("createNewFile operation failed for: " + file);
588 Log.i(TAG, "Created new file: " + file);
590 return file;
611 row.add(Document.COLUMN_DISPLAY_NAME, document.file.getName());
612 row.add(Document.COLUMN_SIZE, document.file.length());
615 row.add(Document.COLUMN_LAST_MODIFIED, document.file.lastModified());
618 private void removeChildrenRecursively(File file) {
619 for (File childFile : file.listFiles()) {
650 final File file = createFile(rootId, path, mimeType, content);
651 final StubDocument parent = mStorage.get(getDocumentIdForFile(file.getParentFile()));
655 final StubDocument document = StubDocument.createRegularDocument(file, mimeType, parent);
665 final File file = createFile(rootId, path, mimeType, content);
666 final StubDocument parent = mStorage.get(getDocumentIdForFile(file.getParentFile()));
671 file, mimeType, streamTypes, parent);
683 File needle = new File(root.file, path.substring(1));
689 return found.file;
694 Log.d(TAG, "Creating test file " + rootId + " : " + path);
699 final File file = new File(root.file, path.substring(1));
701 if (!file.mkdirs()) {
702 throw new FileNotFoundException("Couldn't create directory " + file.getPath());
705 if (!file.createNewFile()) {
706 throw new FileNotFoundException("Couldn't create file " + file.getPath());
708 try (final FileOutputStream fout = new FileOutputStream(file)) {
712 return file;
725 RootInfo(File file, long capacity) {
726 this.name = file.getName();
731 this.document = StubDocument.createRootDocument(file, this);
746 public final File file;
754 private StubDocument(File file, String mimeType, List<String> streamTypes, int flags,
756 this.file = file;
757 this.documentId = getDocumentIdForFile(file);
765 private StubDocument(File file, RootInfo rootInfo) {
766 this.file = file;
767 this.documentId = getDocumentIdForFile(file);
775 public static StubDocument createRootDocument(File file, RootInfo rootInfo) {
776 return new StubDocument(file, rootInfo);
780 File file, String mimeType, StubDocument parent) {
782 if (file.isDirectory()) {
787 return new StubDocument(file, mimeType, new ArrayList<String>(), flags, parent);
791 File file, String mimeType, StubDocument parent, int flags,
793 return new StubDocument(file, mimeType, streamTypes, flags, parent);
797 File file, String mimeType, List<String> streamTypes, StubDocument parent) {
800 return new StubDocument(file, mimeType, streamTypes, flags, parent);
806 + "path:" + file.getPath()
817 private static String getDocumentIdForFile(File file) {
818 return file.getAbsolutePath();