List of usage examples for android.os FileUtils setPermissions
@UnsupportedAppUsage public static int setPermissions(FileDescriptor fd, int mode, int uid, int gid)
From source file:android.util.AtomicFile.java
/** * Start a new write operation on the file. This returns a FileOutputStream * to which you can write the new file data. The existing file is replaced * with the new data. You <em>must not</em> directly close the given * FileOutputStream; instead call either {@link #finishWrite(FileOutputStream)} * or {@link #failWrite(FileOutputStream)}. * * <p>Note that if another thread is currently performing * a write, this will simply replace whatever that thread is writing * with the new file being written by this thread, and when the other * thread finishes the write the new write operation will no longer be * safe (or will be lost). You must do your own threading protection for * access to AtomicFile./*from www. jav a2 s. c o m*/ */ public FileOutputStream startWrite() throws IOException { // Rename the current file so it may be used as a backup during the next read if (mBaseName.exists()) { if (!mBackupName.exists()) { if (!mBaseName.renameTo(mBackupName)) { Log.w("AtomicFile", "Couldn't rename file " + mBaseName + " to backup file " + mBackupName); } } else { mBaseName.delete(); } } FileOutputStream str = null; try { str = new FileOutputStream(mBaseName); } catch (FileNotFoundException e) { File parent = mBaseName.getParentFile(); if (!parent.mkdir()) { throw new IOException("Couldn't create directory " + mBaseName); } FileUtils.setPermissions(parent.getPath(), FileUtils.S_IRWXU | FileUtils.S_IRWXG | FileUtils.S_IXOTH, -1, -1); try { str = new FileOutputStream(mBaseName); } catch (FileNotFoundException e2) { throw new IOException("Couldn't create " + mBaseName); } } return str; }
From source file:cn.dacas.providers.downloads.DownloadThread.java
/** * Called after a successful completion to take any necessary action on the * downloaded file.//ww w .jav a 2 s . co m */ private void finalizeDestinationFile(State state) throws StopRequest { // make sure the file is readable FileUtils.setPermissions(state.mFilename, 0644, -1, -1); syncDestination(state); }
From source file:com.android.providers.downloads.DownloadThread.java
/** * Called after a successful completion to take any necessary action on the downloaded file. *///from w w w . j a v a 2 s . com private void finalizeDestinationFile(State state) throws StopRequest { if (isDrmFile(state)) { transferToDrm(state); } else { // make sure the file is readable FileUtils.setPermissions(state.mFilename, 0644, -1, -1); syncDestination(state); } }
From source file:cn.keyshare.download.core.DownloadThread.java
/** * Called after a successful completion to take any necessary action on the * downloaded file.//from w w w .ja v a2s . c om */ private void finalizeDestinationFile(State state) throws StopRequest { // make sure the file is readable FileUtils.setPermissions(state.mFilename, 0644, -1, -1); syncDestination(state); }