internal void AddPathList(FileIOPermissionAccess access, String[] pathList, bool checkForDuplicates, bool needFullPath) { VerifyAccess(access); if (pathList == null) { throw new ArgumentNullException("pathList"); } if (pathList.Length == 0) { throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath")); } HasIllegalCharacters(pathList); m_unrestricted = false; if ((access & FileIOPermissionAccess.Read) != 0) { if (m_read == null) { m_read = new FileIOAccess(); } m_read.AddExpressions(pathList, checkForDuplicates, needFullPath); } if ((access & FileIOPermissionAccess.Write) != 0) { if (m_write == null) { m_write = new FileIOAccess(); } m_write.AddExpressions(pathList, checkForDuplicates, needFullPath); } if ((access & FileIOPermissionAccess.Append) != 0) { if (m_append == null) { m_append = new FileIOAccess(); } m_append.AddExpressions(pathList, checkForDuplicates, needFullPath); } if ((access & FileIOPermissionAccess.PathDiscovery) != 0) { if (m_pathDiscovery == null) { m_pathDiscovery = new FileIOAccess(true); } m_pathDiscovery.AddExpressions(pathList, checkForDuplicates, needFullPath); } }
[System.Security.SecurityCritical] // auto-generated internal void AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, bool checkForDuplicates, bool needFullPath, bool copyPathList) { if (pathListOrig == null) { throw new ArgumentNullException("pathList"); } if (pathListOrig.Length == 0) { throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath")); } Contract.EndContractBlock(); VerifyAccess(access); if (m_unrestricted) { return; } String[] pathList = pathListOrig; if (copyPathList) { // Make a copy of pathList (in case its value changes after we check for illegal chars) pathList = new String[pathListOrig.Length]; Array.Copy(pathListOrig, pathList, pathListOrig.Length); } ArrayList pathArrayList = StringExpressionSet.CreateListFromExpressions(pathList, needFullPath); // If we need the full path the standard illegal characters will be checked in StringExpressionSet. CheckIllegalCharacters(pathList, onlyCheckExtras: needFullPath); // StringExpressionSet will do minor normalization, trimming spaces and replacing alternate // directory separators. It will make an attemt to expand short file names and will check // for standard colon placement. // // If needFullPath is true it will call NormalizePath- which performs short name expansion // and does the normal validity checks. if ((access & FileIOPermissionAccess.Read) != 0) { if (m_read == null) { m_read = new FileIOAccess(); } m_read.AddExpressions(pathArrayList, checkForDuplicates); } if ((access & FileIOPermissionAccess.Write) != 0) { if (m_write == null) { m_write = new FileIOAccess(); } m_write.AddExpressions(pathArrayList, checkForDuplicates); } if ((access & FileIOPermissionAccess.Append) != 0) { if (m_append == null) { m_append = new FileIOAccess(); } m_append.AddExpressions(pathArrayList, checkForDuplicates); } if ((access & FileIOPermissionAccess.PathDiscovery) != 0) { if (m_pathDiscovery == null) { m_pathDiscovery = new FileIOAccess(true); } m_pathDiscovery.AddExpressions(pathArrayList, checkForDuplicates); } }
[System.Security.SecurityCritical] // auto-generated internal void AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, bool checkForDuplicates, bool needFullPath, bool copyPathList) { if (pathListOrig == null) { throw new ArgumentNullException("pathList"); } if (pathListOrig.Length == 0) { throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath")); } Contract.EndContractBlock(); VerifyAccess(access); if (m_unrestricted) { return; } String[] pathList = pathListOrig; if (copyPathList) { // Make a copy of pathList (in case its value changes after we check for illegal chars) pathList = new String[pathListOrig.Length]; Array.Copy(pathListOrig, pathList, pathListOrig.Length); } CheckIllegalCharacters(pathList); ArrayList pathArrayList = StringExpressionSet.CreateListFromExpressions(pathList, needFullPath); if ((access & FileIOPermissionAccess.Read) != 0) { if (m_read == null) { m_read = new FileIOAccess(); } m_read.AddExpressions(pathArrayList, checkForDuplicates); } if ((access & FileIOPermissionAccess.Write) != 0) { if (m_write == null) { m_write = new FileIOAccess(); } m_write.AddExpressions(pathArrayList, checkForDuplicates); } if ((access & FileIOPermissionAccess.Append) != 0) { if (m_append == null) { m_append = new FileIOAccess(); } m_append.AddExpressions(pathArrayList, checkForDuplicates); } if ((access & FileIOPermissionAccess.PathDiscovery) != 0) { if (m_pathDiscovery == null) { m_pathDiscovery = new FileIOAccess(true); } m_pathDiscovery.AddExpressions(pathArrayList, checkForDuplicates); } #if FEATURE_MACL if ((control & AccessControlActions.View) != 0) { if (m_viewAcl == null) { m_viewAcl = new FileIOAccess(); } m_viewAcl.AddExpressions(pathArrayList, checkForDuplicates); } if ((control & AccessControlActions.Change) != 0) { if (m_changeAcl == null) { m_changeAcl = new FileIOAccess(); } m_changeAcl.AddExpressions(pathArrayList, checkForDuplicates); } #endif }
internal void AddPathList(FileIOPermissionAccess access, String[] pathListOrig, bool checkForDuplicates, bool needFullPath, bool copyPathList) { VerifyAccess(access); if (pathListOrig == null) { throw new ArgumentNullException("pathList"); } if (pathListOrig.Length == 0) { throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath")); } String[] pathList = pathListOrig; if (copyPathList) { // Make a copy of pathList (in case its value changes after we check for illegal chars) pathList = new String[pathListOrig.Length]; Array.Copy(pathListOrig, pathList, pathListOrig.Length); } HasIllegalCharacters(pathList); m_unrestricted = false; if ((access & FileIOPermissionAccess.Read) != 0) { if (m_read == null) { m_read = new FileIOAccess(); } m_read.AddExpressions(pathList, checkForDuplicates, needFullPath); } if ((access & FileIOPermissionAccess.Write) != 0) { if (m_write == null) { m_write = new FileIOAccess(); } m_write.AddExpressions(pathList, checkForDuplicates, needFullPath); } if ((access & FileIOPermissionAccess.Append) != 0) { if (m_append == null) { m_append = new FileIOAccess(); } m_append.AddExpressions(pathList, checkForDuplicates, needFullPath); } if ((access & FileIOPermissionAccess.PathDiscovery) != 0) { if (m_pathDiscovery == null) { m_pathDiscovery = new FileIOAccess(true); } m_pathDiscovery.AddExpressions(pathList, checkForDuplicates, needFullPath); } }
private static FileIOAccess FileIOAccessFromPath(string fullPath) { FileIOAccess access = new FileIOAccess(); #if FEATURE_WINDOWSPHONE // Due to an interaction between the ACLs on the phone for the directories isolated storage lives in // and GetLongPathNameW (which StringExpressionSet.CreateListFromExpressions ends up calling if the // path name has a ~ in it), we remove all ~'s before constructing the path to demand. // // The risk here is the case where there's a short file name that resolves to a path not under the root // of Isolated Storage, but in that case either the Win32 ACLs will prevent access or the user could // have accessed the files anyway. Since Isolated Storage is not a security boundary in Windows Phone // we are not concerned about this case. fullPath = fullPath.Replace("~", ""); #endif ArrayList expressions = StringExpressionSet.CreateListFromExpressions(new string[] { fullPath }, true); access.AddExpressions(expressions, false); return access; }