public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut <UiStringKey> reason = null) { if (ioc.IsLocalFile()) { if (IsLocalFileFlaggedReadOnly(ioc)) { if (reason != null) { reason.Result = UiStringKey.ReadOnlyReason_ReadOnlyFlag; } return(true); } if (IsReadOnlyBecauseKitkatRestrictions(ioc)) { if (reason != null) { reason.Result = UiStringKey.ReadOnlyReason_ReadOnlyKitKat; } return(true); } return(false); } //for remote files assume they can be written: (think positive! :-) ) return(false); }
public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut <UiStringKey> reason = null) { ICursor cursor = null; try { //on pre-Kitkat devices, we can't write content:// files if (!IsKitKatOrLater) { Kp2aLog.Log("File is read-only because we're not on KitKat or later."); if (reason != null) { reason.Result = UiStringKey.ReadOnlyReason_PreKitKat; } return(true); } //in previous implementations, we were checking for FLAG_SUPPORTS_WRITE in the document flags, //but it seems like this is very poorly supported, e.g. Dropbox and OneDrive return !FLAG_SUPPORTS_WRITE //even though writing work. return(false); } catch (Exception e) { Kp2aLog.LogUnexpectedError(e); //better return false here. We don't really know what happened (as this is unexpected). //let the user try to write the file. If it fails they will get an exception string. return(false); } finally { if (cursor != null) { cursor.Close(); } } }
public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut <UiStringKey> reason = null) { ICursor cursor = null; try { //on pre-Kitkat devices, we can't write content:// files if (!IsKitKatOrLater) { Kp2aLog.Log("File is read-only because we're not on KitKat or later."); if (reason != null) { reason.Result = UiStringKey.ReadOnlyReason_PreKitKat; } return(true); } //KitKat or later... var uri = Android.Net.Uri.Parse(ioc.Path); cursor = _ctx.ContentResolver.Query(uri, null, null, null, null, null); if (cursor != null && cursor.MoveToFirst()) { int column = cursor.GetColumnIndex(DocumentsContract.Document.ColumnFlags); if (column < 0) { return(false); //seems like this is not supported. See below for reasoning to return false. } int flags = cursor.GetInt(column); Kp2aLog.Log("File flags: " + flags); if ((flags & (long)DocumentContractFlags.SupportsWrite) == 0) { if (reason != null) { reason.Result = UiStringKey.ReadOnlyReason_ReadOnlyFlag; } return(true); } else { return(false); } } else { throw new Exception("couldn't move to first result element: " + (cursor == null) + uri.ToString()); } } catch (Exception e) { Kp2aLog.LogUnexpectedError(e); //better return false here. We don't really know what happened (as this is unexpected). //let the user try to write the file. If it fails they will get an exception string. return(false); } finally { if (cursor != null) { cursor.Close(); } } }
public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut <UiStringKey> reason = null) { return(false); //TODO implement. note, however, that we MAY return false even if it's read-only }
public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut <UiStringKey> reason = null) { return(false); }
public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut <UiStringKey> reason = null) { return(_baseStorage.IsReadOnly(ioc, reason)); }
public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut <UiStringKey> reason = null) { //even though the cache can always be written, the changes made in the cache could not be transferred to the cached file //so we better treat the cache as read-only as well. return(_cachedStorage.IsReadOnly(ioc, reason)); }