@Override public void onListItemClick(ListView parent, View v, int position, long id) { // Toast.makeText(this, this.currentEntries.get(position).getView(), // Toast.LENGTH_SHORT).show(); ParsedRow clickedRow = EmpsiAdapter.currentData.get(position); int view = Integer.parseInt(clickedRow.getView()); String title = clickedRow.getTitle(); String scroll = clickedRow.getScroll(); FileList fl = new FileList(); String url = fl.getURL(view); Intent i = new Intent(getActivity(), MainActivity.class); i.putExtra("view", url); i.putExtra("title", title); i.putExtra("scroll", scroll); i.setData(Uri.parse(url)); Log.d(TAG, "INTENT: " + title); Log.d(TAG, "INTENT: " + url); Log.d(TAG, "INTENT: " + scroll); // Toast.makeText(this, url, Toast.LENGTH_SHORT).show(); startActivity(i); }
public void go() { FileList fl = null; try { fl = new FileList(inputPath); fl.read(); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } Queue<File> filesQ = fl.getFiles(); LOG.info("Found " + filesQ.size() + " files to process"); int c = 1; for (File file : filesQ) { String sum = null; String date = null; String type = getType(file); System.out.print(c + " "); if ((c % 20) == 0) { System.out.println(); } c++; if (imageFile(type)) { try { sum = SHA256.digest(file); } catch (IOException e) { LOG.info("NOSHA: IO: " + file.getAbsolutePath()); } try { date = getDate(file); } catch (IOException e) { LOG.info("NODATE: IO: " + file.getAbsolutePath()); } if (sum != null && date != null) { storePhotoInfo(sum, date, file.getAbsolutePath()); } } else { LOG.info("SKIP: skipping non-image file: " + file.getAbsolutePath()); } } for (Photo p : pstore.getPhotos()) { savePhoto(p); } }
public List<String> getFilenames() { ArrayList<String> result = new ArrayList<String>(); JavaScriptObject rawFileList = getElement().getPropertyJSO("files"); if (rawFileList == null) { result.add(InputElement.as(getElement()).getValue()); // IE does not support multiple-select } else { FileList fileList = rawFileList.cast(); for (int i = 0; i < fileList.getLength(); ++i) { result.add(fileList.item(i).getName()); } } return result; }
public Node convertToXML(Document parent) { Element targetNode = parent.createElement(ELEMENT_NAME); if (ident != null) targetNode.setAttribute(ATTRIBUTE_IDENT, ident); if (decoy != null) targetNode.setAttribute(ATTRIBUTE_DECOY, decoy); if (networkInterface != null) targetNode.setAttribute(ATTRIBUTE_INTERFACE, networkInterface); if (node != null) { Node nodeNode = node.convertToXML(parent); targetNode.appendChild(nodeNode); } if (user != null) { Node userNode = user.convertToXML(parent); targetNode.appendChild(userNode); } if (process != null) { Node processNode = process.convertToXML(parent); targetNode.appendChild(processNode); } if (service != null) { Node serviceNode = service.convertToXML(parent); targetNode.appendChild(serviceNode); } if (fileList != null) { targetNode.appendChild(fileList.convertToXML(parent)); } return targetNode; }
/** Sorts bigger FileList instances before smaller ones. */ public final int compareTo(FileList o) { if (blocks != o.blocks) return o.blocks - blocks; if (this == o) return 0; if (hashCode() < o.hashCode()) return -1; if (hashCode() > o.hashCode()) return 1; return 0; }
/** Adds a disk log file to in-memory tracking for accounting and enumeration. */ private synchronized void enrollEntry(EntryFile entry) { mAllFiles.contents.add(entry); mAllFiles.blocks += entry.blocks; // mFilesByTag is used for trimming, so don't list empty files. // (Zero-length/lost files are trimmed by date from mAllFiles.) if (entry.tag != null && entry.file != null && entry.blocks > 0) { FileList tagFiles = mFilesByTag.get(entry.tag); if (tagFiles == null) { tagFiles = new FileList(); mFilesByTag.put(entry.tag, tagFiles); } tagFiles.contents.add(entry); tagFiles.blocks += entry.blocks; } }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.folderex); Intent gintent = getIntent(); getPath = gintent.getStringExtra("path"); dbPath = gintent.getStringExtra("dbpath"); FileList _FileList = new FileList(this); _FileList.setOnPathChangedListener(_OnPathChanged); _FileList.setOnFileSelected(_OnFileSelected); LinearLayout layout = (LinearLayout) findViewById(R.id.LinearLayout01); layout.addView(_FileList); Util.print("getPath = " + getPath); String path = " "; if (getPath.equals("empty")) { File root = Environment.getExternalStorageDirectory(); _FileList.setPath(root.getAbsolutePath()); path = root.getAbsolutePath(); } else { _FileList.setPath(getPath); path = getPath; } Util.print("path = " + path); _FileList.setFocusable(true); _FileList.setFocusableInTouchMode(true); ((TextView) findViewById(R.id.TextView01)).setSelected(true); }
/** Moves a temporary file to a final log filename and enrolls it. */ private synchronized long createEntry(File temp, String tag, int flags) throws IOException { long t = System.currentTimeMillis(); // Require each entry to have a unique timestamp; if there are entries // >10sec in the future (due to clock skew), drag them back to avoid // keeping them around forever. SortedSet<EntryFile> tail = mAllFiles.contents.tailSet(new EntryFile(t + 10000)); EntryFile[] future = null; if (!tail.isEmpty()) { future = tail.toArray(new EntryFile[tail.size()]); tail.clear(); // Remove from mAllFiles } if (!mAllFiles.contents.isEmpty()) { t = Math.max(t, mAllFiles.contents.last().timestampMillis + 1); } if (future != null) { for (EntryFile late : future) { mAllFiles.blocks -= late.blocks; FileList tagFiles = mFilesByTag.get(late.tag); if (tagFiles != null && tagFiles.contents.remove(late)) { tagFiles.blocks -= late.blocks; } if ((late.flags & DropBoxManager.IS_EMPTY) == 0) { enrollEntry(new EntryFile(late.file, mDropBoxDir, late.tag, t++, late.flags, mBlockSize)); } else { enrollEntry(new EntryFile(mDropBoxDir, late.tag, t++)); } } } if (temp == null) { enrollEntry(new EntryFile(mDropBoxDir, tag, t)); } else { enrollEntry(new EntryFile(temp, mDropBoxDir, tag, t, flags, mBlockSize)); } return t; }
public void showFileList(RestResource r, boolean clearSelection) { RestResource currentFolder = r; if (currentFolder != null) { List<FileResource> files = null; if (currentFolder instanceof RestResourceWrapper) { RestResourceWrapper folder = (RestResourceWrapper) currentFolder; files = folder.getResource().getFiles(); } else if (currentFolder instanceof TrashResource) { TrashResource folder = (TrashResource) currentFolder; files = folder.getFiles(); } else if (currentFolder instanceof SharedResource) { SharedResource folder = (SharedResource) currentFolder; files = folder.getFiles(); } else if (currentFolder instanceof OtherUserResource) { OtherUserResource folder = (OtherUserResource) currentFolder; files = folder.getFiles(); } if (files != null) getFileList().setFiles(files); else getFileList().setFiles(new ArrayList<FileResource>()); } fileList.updateFileCache(clearSelection /*clear selection*/); inner.selectTab(0); }
/** Make the file list visible. */ public void showFileList() { fileList.updateFileCache(true /*clear selection*/); inner.selectTab(0); }
/** * Trims the files on disk to make sure they aren't using too much space. * * @return the overall quota for storage (in bytes) */ private synchronized long trimToFit() { // Expunge aged items (including tombstones marking deleted data). int ageSeconds = Settings.Global.getInt( mContentResolver, Settings.Global.DROPBOX_AGE_SECONDS, DEFAULT_AGE_SECONDS); int maxFiles = Settings.Global.getInt( mContentResolver, Settings.Global.DROPBOX_MAX_FILES, DEFAULT_MAX_FILES); long cutoffMillis = System.currentTimeMillis() - ageSeconds * 1000; while (!mAllFiles.contents.isEmpty()) { EntryFile entry = mAllFiles.contents.first(); if (entry.timestampMillis > cutoffMillis && mAllFiles.contents.size() < maxFiles) break; FileList tag = mFilesByTag.get(entry.tag); if (tag != null && tag.contents.remove(entry)) tag.blocks -= entry.blocks; if (mAllFiles.contents.remove(entry)) mAllFiles.blocks -= entry.blocks; if (entry.file != null) entry.file.delete(); } // Compute overall quota (a fraction of available free space) in blocks. // The quota changes dynamically based on the amount of free space; // that way when lots of data is available we can use it, but we'll get // out of the way if storage starts getting tight. long uptimeMillis = SystemClock.uptimeMillis(); if (uptimeMillis > mCachedQuotaUptimeMillis + QUOTA_RESCAN_MILLIS) { int quotaPercent = Settings.Global.getInt( mContentResolver, Settings.Global.DROPBOX_QUOTA_PERCENT, DEFAULT_QUOTA_PERCENT); int reservePercent = Settings.Global.getInt( mContentResolver, Settings.Global.DROPBOX_RESERVE_PERCENT, DEFAULT_RESERVE_PERCENT); int quotaKb = Settings.Global.getInt( mContentResolver, Settings.Global.DROPBOX_QUOTA_KB, DEFAULT_QUOTA_KB); mStatFs.restat(mDropBoxDir.getPath()); int available = mStatFs.getAvailableBlocks(); int nonreserved = available - mStatFs.getBlockCount() * reservePercent / 100; int maximum = quotaKb * 1024 / mBlockSize; mCachedQuotaBlocks = Math.min(maximum, Math.max(0, nonreserved * quotaPercent / 100)); mCachedQuotaUptimeMillis = uptimeMillis; } // If we're using too much space, delete old items to make room. // // We trim each tag independently (this is why we keep per-tag lists). // Space is "fairly" shared between tags -- they are all squeezed // equally until enough space is reclaimed. // // A single circular buffer (a la logcat) would be simpler, but this // way we can handle fat/bursty data (like 1MB+ bugreports, 300KB+ // kernel crash dumps, and 100KB+ ANR reports) without swamping small, // well-behaved data streams (event statistics, profile data, etc). // // Deleted files are replaced with zero-length tombstones to mark what // was lost. Tombstones are expunged by age (see above). if (mAllFiles.blocks > mCachedQuotaBlocks) { // Find a fair share amount of space to limit each tag int unsqueezed = mAllFiles.blocks, squeezed = 0; TreeSet<FileList> tags = new TreeSet<FileList>(mFilesByTag.values()); for (FileList tag : tags) { if (squeezed > 0 && tag.blocks <= (mCachedQuotaBlocks - unsqueezed) / squeezed) { break; } unsqueezed -= tag.blocks; squeezed++; } int tagQuota = (mCachedQuotaBlocks - unsqueezed) / squeezed; // Remove old items from each tag until it meets the per-tag quota. for (FileList tag : tags) { if (mAllFiles.blocks < mCachedQuotaBlocks) break; while (tag.blocks > tagQuota && !tag.contents.isEmpty()) { EntryFile entry = tag.contents.first(); if (tag.contents.remove(entry)) tag.blocks -= entry.blocks; if (mAllFiles.contents.remove(entry)) mAllFiles.blocks -= entry.blocks; try { if (entry.file != null) entry.file.delete(); enrollEntry(new EntryFile(mDropBoxDir, entry.tag, entry.timestampMillis)); } catch (IOException e) { Slog.e(TAG, "Can't write tombstone file", e); } } } } return mCachedQuotaBlocks * mBlockSize; }
/** * Adds a nested <code><filelist></code> element. * * @param fl a <code>FileList</code> to be added to the path * @throws BuildException on error */ public void addFilelist(FileList fl) throws BuildException { if (fl.getProject() == null) { fl.setProject(getProject()); } add(fl); }