コード例 #1
0
 public override bool GetTrackPath(TrackInfo track, out string path)
 {
     path = FileNamePattern.CreateFromTrackInfo(
         "%artist%%path_sep%%album%%path_sep%%track_number%. %title%",
         track);
     return(true);
 }
コード例 #2
0
 public void InvalidPathChars(char pattern)
 {
     Assert.Throws <PatternSyntaxException>(() => FileNamePattern.Parse(pattern.ToString()));
     Assert.Throws <PatternSyntaxException>(() => FileNamePattern.Parse("pre" + pattern.ToString()));
     Assert.Throws <PatternSyntaxException>(() => FileNamePattern.Parse(pattern.ToString() + "post"));
     Assert.Throws <PatternSyntaxException>(() => FileNamePattern.Parse("pre" + pattern.ToString() + "post"));
 }
コード例 #3
0
 private IEnumerable <FileInfo> GetFilesSinceLastUpdate()
 {
     return(Directory.GetFiles(_logDirectoryPath)
            .Where(x => FileNamePattern?.IsMatch(x) ?? false)
            .Select(x => new FileInfo(x))
            .Where(x => x.LastWriteTime >= _lastUpdatedOn));
 }
コード例 #4
0
            private void OnChanged(object o, EventArgs args)
            {
                string display = FileNamePattern.CreateFromTrackInfo(FileNamePattern.CreateFolderFilePattern(
                                                                         folder.ActiveValue, file.ActiveValue), track);

                Markup = String.IsNullOrEmpty(display) ? String.Empty : String.Format("<small>{0}.ogg</small>",
                                                                                      GLib.Markup.EscapeText(display));
            }
コード例 #5
0
        public void ParseEmpty(string pattern)
        {
            var res = FileNamePattern.Parse(pattern);

            Assert.NotNull(res);
            Assert.Empty(res.Tokens);
            Assert.True(res.IsEmpty);
        }
コード例 #6
0
        public void ParseTest(string pattern)
        {
            // var data = FileMetadata.DemoMetadata;
            var res = FileNamePattern.Parse(pattern);

            Assert.NotNull(res);
            Assert.NotEmpty(res.Tokens);
            Assert.False(res.IsEmpty);
        }
コード例 #7
0
        public void OptionalTokenShouldBeEmptyIfZero()
        {
            var track = new TrackInfo {
                DiscNumber = 0
            };
            var pattern = "{ (disc %disc_number%)}";

            Assert.IsEmpty(FileNamePattern.Convert(pattern, conversion => conversion.Handler(track, null)));
        }
コード例 #8
0
        public void OptionalTokenShouldBeEmptyIfEmpty()
        {
            var track = new TrackInfo {
                Genre = ""
            };
            var pattern = "{ (%genre%)}";

            Assert.IsEmpty(FileNamePattern.Convert(pattern, conversion => conversion.Handler(track, null)));
        }
コード例 #9
0
ファイル: Settings.cs プロジェクト: Goletas/screencapture
 internal Settings()
 {
     this._IncludeCursor = true;
     this._ImageDestinations = ImageDestinations.Clipboard;
     this._WorkingDirectory = string.Empty; // make "my pictures" default?
     this._ExternalApp = string.Empty;
     this._FileNameFormat = string.Empty;
     this._FileNameFormat = "<yyyy>.<MM>.<dd> <hh>-<mm>-<ss>";
     this._FileNamePattern = FileNamePattern.DateTime;
       //  this._FileType = new PngFileType();
 }
コード例 #10
0
 internal Settings()
 {
     this._IncludeCursor     = true;
     this._ImageDestinations = ImageDestinations.Clipboard;
     this._WorkingDirectory  = string.Empty; // make "my pictures" default?
     this._ExternalApp       = string.Empty;
     this._FileNameFormat    = string.Empty;
     this._FileNameFormat    = "<yyyy>.<MM>.<dd> <hh>-<mm>-<ss>";
     this._FileNamePattern   = FileNamePattern.DateTime;
     //  this._FileType = new PngFileType();
 }
コード例 #11
0
        private string CreateFilePath(FileNamePattern fileNamePattern, bool addTmpSubdir = false)
        {
            // Build image name
            string imageName;

            if (fileNamePattern == FileNamePattern.Numbered)
            {
                imageName = CreateImageNameNumbered();
            }
            else
            {
                imageName = CreateImageNameDateTime();
            }
            // Create path and subdirectory
            string path = PRModSettings.exportPath;

            if (PRModSettings.createSubdirs)
            {
                path = Path.Combine(path, Find.World.info.seedString);
            }
            Directory.CreateDirectory(path);
            // Add subdir for manually triggered renderings
            if (manuallyTriggered)
            {
                path = Path.Combine(path, "manually");
                Directory.CreateDirectory(path);
            }
            // Create additional subdir for numbered symlinks
            if (addTmpSubdir)
            {
                path = Path.Combine(path, "tmp");
                Directory.CreateDirectory(path);
            }
            // Get correct file and location
            string fileExt  = EnumUtils.GetFileExtension(PRModSettings.encoding);
            string filePath = Path.Combine(path, imageName + "." + fileExt);

            if (!File.Exists(filePath))
            {
                return(filePath);
            }
            int i = 1;

            filePath = Path.Combine(path, imageName);
            string newPath;

            do
            {
                newPath = filePath + "-alt" + i + "." + fileExt;
                i++;
            }while (File.Exists(newPath));
            return(newPath);
        }
コード例 #12
0
        public bool CopyToLibraryIfAppropriate(bool force_copy)
        {
            bool copy_success = true;

            SafeUri old_uri = this.Uri;

            if (old_uri == null)
            {
                // Get out quick, no URI set yet.
                return(copy_success);
            }

            bool in_library = old_uri.AbsolutePath.StartsWith(PrimarySource.BaseDirectoryWithSeparator);

            if (!in_library && (LibrarySchema.CopyOnImport.Get() || force_copy))
            {
                string  new_filename = FileNamePattern.BuildFull(PrimarySource.BaseDirectory, this, Path.GetExtension(old_uri.ToString()));
                SafeUri new_uri      = new SafeUri(new_filename);

                try {
                    if (Banshee.IO.File.Exists(new_uri))
                    {
                        if (Banshee.IO.File.GetSize(old_uri) == Banshee.IO.File.GetSize(new_uri))
                        {
                            Hyena.Log.DebugFormat("Not copying {0} to library because there is already a file of same size at {1}", old_uri, new_uri);
                            copy_success = false;
                            return(copy_success);
                        }
                        else
                        {
                            string extension       = Path.GetExtension(new_filename);
                            string filename_no_ext = new_filename.Remove(new_filename.Length - extension.Length);
                            int    duplicate_index = 1;
                            while (Banshee.IO.File.Exists(new_uri))
                            {
                                new_filename = String.Format("{0} ({1}){2}", filename_no_ext, duplicate_index, extension);
                                new_uri      = new SafeUri(new_filename);
                                duplicate_index++;
                            }
                        }
                    }

                    Banshee.IO.File.Copy(old_uri, new_uri, false);
                    Uri = new_uri;
                } catch (Exception e) {
                    Log.ErrorFormat("Exception copying into library: {0}", e);
                }
            }
            return(copy_success);
        }
コード例 #13
0
        public PlaylistExportDialog(string name, Window parent) :
            base(Catalog.GetString("Export Playlist"), parent, FileChooserAction.Save)
        {
            initial_name = FileNamePattern.Escape (name);
            playlist = PlaylistFileUtil.GetDefaultExportFormat();
            CurrentName = System.IO.Path.ChangeExtension(initial_name, playlist.FileExtension);
            DefaultResponse = ResponseType.Ok;
            DoOverwriteConfirmation = true;

            AddButton(Stock.Cancel, ResponseType.Cancel);
            AddButton(Catalog.GetString("Export"), ResponseType.Ok);

            InitializeExtraWidget();
        }
コード例 #14
0
        public void CreateFromTrackInfo()
        {
            SampleTrackInfo track = new SampleTrackInfo();
            string          built = FileNamePattern.CreateFromTrackInfo(
                "%artist%:%album%:%title%:%track_number%:" +
                "%track_count%:%track_number_nz%:%track_count_nz%",
                track);

            Assert.AreEqual(String.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}",
                                          track.ArtistName, track.AlbumTitle, track.TrackTitle,
                                          ZeroPad(track.TrackNumber), ZeroPad(track.TrackCount),
                                          track.TrackNumber, track.TrackCount),
                            built);
        }
コード例 #15
0
        /// <summary>
        /// Searches an XML file with an XPath expression
        /// </summary>
        /// <param name="context"></param>
        protected override void Execute(CodeActivityContext context)
        {
            // get the value of the XPathExpression
            var fileNamePattern = FileNamePattern.Get(context);

            // get the value of the FilePath
            var searchFolder = SearchFolder.Get(context);

            var filePath = FindFile(fileNamePattern, searchFolder);

            context.WriteBuildMessage(string.Format("Path found: {0}", filePath), BuildMessageImportance.High);

            // return the value
            FullFilePath.Set(context, filePath);
        }
コード例 #16
0
        public static string ToFriendlyString(FileNamePattern type)
        {
            switch (type)
            {
            case FileNamePattern.DateTime:
                return("DateTime");

            case FileNamePattern.Numbered:
                return("Numbered");

            case FileNamePattern.BothTmpCopy:
                return("BothTmpCopy");
            }
            return("DateTime");
        }
コード例 #17
0
        public static string GetFileNameFromPattern(FileMetadata info, string pattern)
        {
            if (pattern == null)
            {
                throw new ArgumentNullException(nameof(pattern));
            }

            var parsedPattern = FileNamePattern.Parse(pattern);

            if (parsedPattern.IsEmpty)
            {
                throw new PatternSyntaxException();
            }

            return(parsedPattern.FormatMetadata(info));
        }
コード例 #18
0
 internal static MessageStatus WorkaroundQueryDirectoryInfo(FileNamePattern fileNamePattern, bool isNoRecordsReturned, bool isOutBufferSizeLess, MessageStatus returnedStatus, ITestSite site)
 {
     if (isOutBufferSizeLess)
     {
         returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(4836, MessageStatus.INFO_LENGTH_MISMATCH, returnedStatus, site);
     }
     else if (fileNamePattern == FileNamePattern.NotValidFilenameComponent)
     {
         returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(849, MessageStatus.OBJECT_NAME_INVALID, returnedStatus, site);
     }
     else if (isNoRecordsReturned)
     {
         returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(865, MessageStatus.NO_SUCH_FILE, returnedStatus, site);
     }
     return(returnedStatus);
 }
コード例 #19
0
        protected override void AddTrack(DatabaseTrackInfo track)
        {
            // Ignore if already have it
            if (track.PrimarySourceId == DbId)
            {
                return;
            }

            PrimarySource source = track.PrimarySource;

            // If it's from a local primary source, change it's PrimarySource
            if (source.IsLocal || source is LibrarySource)
            {
                track.PrimarySource = this;

                if (!(source is LibrarySource))
                {
                    track.CopyToLibraryIfAppropriate(false);
                }

                track.Save(false);
                source.NotifyTracksChanged();
            }
            else
            {
                // Figure out where we should put it if were to copy it
                string  path = FileNamePattern.BuildFull(BaseDirectory, track);
                SafeUri uri  = new SafeUri(path);

                // Make sure it's not already in the library
                // TODO optimize - no need to recrate this int [] every time
                if (DatabaseTrackInfo.ContainsUri(uri, new int [] { DbId }))
                {
                    return;
                }

                // Since it's not, copy it and create a new TrackInfo object
                track.PrimarySource.CopyTrackTo(track, uri, AddTrackJob);

                // Create a new entry in CoreTracks for the copied file
                DatabaseTrackInfo new_track = new DatabaseTrackInfo(track);
                new_track.Uri           = uri;
                new_track.PrimarySource = this;
                new_track.Save(false);
            }
        }
コード例 #20
0
        public override CriterionResult Validate(string path)
        {
            CriterionResult baseResult = base.Validate(path);

            if (!baseResult.IsValid)
            {
                return(baseResult);
            }
            //setup the full path by safely adding the extra path.
            string fullPath = Path.Combine(path, SubPath?.Trim('\\') ?? "");
            //next step down directories based on the depth specified
            var directories = fullPath.GetDirectoriesAtDepth(Depth);
            var patterns    = FileNamePattern.Split(',');

            if (directories != null && directories.Any())
            {
                //check the file pattern
                foreach (var dir in directories)
                {
                    foreach (var pattern in patterns)
                    {
                        if (Directory.GetFiles(dir, pattern).Any())
                        {
                            return(new CriterionResult()
                            {
                                Description = Description,
                                IsValid = true,
                                Message = $"You have a '{FileNamePattern}' file {Depth} folders deep in your in your '{SubPath}' folder."
                            });
                        }
                    }
                }
            }
            //if we end up here the file is not found
            return(new CriterionResult()
            {
                Description = Description,
                IsValid = false,
                Message = $"Could not find a file like '{FileNamePattern}' {Depth} folders down from the '{SubPath}' folder."
            });
        }
コード例 #21
0
        private void RipNextTrack()
        {
            if (queue.Count == 0)
            {
                OnFinished();
                Dispose();
                return;
            }

            AudioCdTrackInfo track = queue.Dequeue();

            user_job.Title = String.Format(Catalog.GetString("Importing {0} of {1}"),
                                           ++track_index, source.DiscModel.EnabledCount);
            status          = String.Format("{0} - {1}", track.ArtistName, track.TrackTitle);
            user_job.Status = status;

            SafeUri uri = new SafeUri(FileNamePattern.BuildFull(ServiceManager.SourceManager.MusicLibrary.BaseDirectory, track, null));
            bool    tagging_supported;

            ripper.RipTrack(track.IndexOnDisc, track, uri, out tagging_supported);
        }
コード例 #22
0
        public void OptionalTokens()
        {
            var track = new TrackInfo {
                ArtistName  = "Esoteric",
                AlbumTitle  = "The Maniacal Vale",
                TrackTitle  = "Silence",
                DiscNumber  = 2,
                DiscCount   = 2,
                TrackNumber = 1,
                Year        = 2008,
                Grouping    = ""
            };
            var pattern =
                "{%grouping%%path_sep%}" +
                "%album_artist%%path_sep%" +
                "{%year% }%album%{ (disc %disc_number% of %disc_count%)}%path_sep%" +
                "{%track_number%. }%title%.oga";

            Assert.AreEqual(
                "Esoteric/2008 The Maniacal Vale (disc 2 of 2)/01. Silence.oga",
                FileNamePattern.Convert(pattern, conversion => conversion.Handler(track, null)));
        }
コード例 #23
0
        public virtual void FromSettings(Settings source)
        {
            if (source == null)
            {
                throw new ArgumentNullException();
            }

            if (!ReferenceEquals(this, source))
            {
                this._FileType          = source._FileType.Clone();
                this._ImageDestinations = source._ImageDestinations;
                this._WorkingDirectory  = source._WorkingDirectory;
                this._AlwaysOnTop       = source._AlwaysOnTop;
                this._AutoStartup       = source._AutoStartup;
                this._UseExternalApp    = source._UseExternalApp;
                this._ExternalApp       = source._ExternalApp;
                this._UseFileOverwrite  = source._UseFileOverwrite;
                this._IncludeCursor     = source._IncludeCursor;
                this._FileNameFormat    = source._FileNameFormat;
                this._FileNamePattern   = source._FileNamePattern;
            }
        }
コード例 #24
0
        private bool RenameFile(DatabaseTrackInfo track)
        {
            SafeUri old_uri    = track.Uri;
            bool    in_library = old_uri.AbsolutePath.StartsWith(source.BaseDirectoryWithSeparator);

            if (!in_library)
            {
                return(false);
            }

            string  new_filename = FileNamePattern.BuildFull(source.BaseDirectory, track, System.IO.Path.GetExtension(old_uri.ToString()));
            SafeUri new_uri      = new SafeUri(new_filename);

            if (!new_uri.Equals(old_uri) && !Banshee.IO.File.Exists(new_uri))
            {
                Banshee.IO.File.Move(old_uri, new_uri);
                Banshee.IO.Utilities.TrimEmptyDirectories(old_uri);
                track.Uri = new_uri;
                return(true);
            }

            return(false);
        }
コード例 #25
0
        private void AcceptTransfer(IncomingFileTransfer transfer)
        {
            if (transfer == null)
            {
                return;
            }

            // passing extension on Uri to allow import after a download
            string ext      = Key.Track.Uri.ToString().Substring(Key.Track.Uri.ToString().LastIndexOf('/') + 1);
            string filename = FileNamePattern.BuildFull(ContactSource.TempDownloadDirectory, Key.Track, ext);

            if (transfer.State == API.Dispatchables.TransferState.LocalPending)
            {
                if (!String.IsNullOrEmpty(filename))
                {
                    transfer.Filename = filename;
                    transfer.Accept();
                }
                else
                {
                    transfer.Accept(ContactSource.TempDownloadDirectory);
                }
            }
        }
コード例 #26
0
            public PatternComboBox(PreferenceBase pref, string [] patterns)
            {
                preference = (Preference <string>)pref;

                bool   already_added = false;
                string conf_pattern  = preference.Value;

                foreach (string pattern in patterns)
                {
                    if (!already_added && pattern.Equals(conf_pattern))
                    {
                        already_added = true;
                    }

                    Add(FileNamePattern.CreatePatternDescription(pattern), pattern);
                }

                if (!already_added)
                {
                    Add(FileNamePattern.CreatePatternDescription(conf_pattern), conf_pattern);
                }

                ActiveValue = conf_pattern;
            }
コード例 #27
0
        public static MessageStatus QueryDirectoryInfo(
            FileNamePattern fileNamePattern,
            bool restartScan,
            bool isNoRecordsReturned,
            bool isOutBufferSizeLess,
            OutBufferSmall outBufferSize)
        {
            MessageStatus returnStatus = MessageStatus.SUCCESS;
            //If OutputBufferSize is less than the size needed to return a single entry
            if (isOutBufferSizeLess)
            {
                switch (outBufferSize)
                {
                    case OutBufferSmall.FileBothDirectoryInformation:
                        {
                            Helper.CaptureRequirement(4881, @"[In FileBothDirectoryInformation] Pseudocode for the operation is as follows:
                                If OutputBufferSize is smaller than FieldOffset( FILE_BOTH_DIR_INFORMATION.FileName ), 
                                the operation MUST be failed with STATUS_INFO_LENGTH_MISMATCH.");
                            return MessageStatus.INFO_LENGTH_MISMATCH;
                        }
                    case OutBufferSmall.FileDirectoryInformation:
                        {
                            Helper.CaptureRequirement(4904, @"[In FileDirectoryInformation] Pseudocode for the operation is as follows:
                                If OutputBufferSize is smaller than FieldOffset( FILE_DIRECTORY_INFORMATION.FileName ), 
                                the operation MUST be failed with STATUS_INFO_LENGTH_MISMATCH.");
                            return MessageStatus.INFO_LENGTH_MISMATCH;
                        }
                    case OutBufferSmall.FileFullDirectoryInformation:
                        {
                            Helper.CaptureRequirement(4920, @"[In FileFullDirectoryInformation] Pseudocode for the operation is as follows:
                                If OutputBufferSize is smaller than FieldOffset( FILE_FULL_DIR_INFORMATION.FileName ), 
                                the operation MUST be failed with STATUS_INFO_LENGTH_MISMATCH.");
                            return MessageStatus.INFO_LENGTH_MISMATCH;
                        }
                    case OutBufferSmall.FileIdBothDirectoryInformation:
                        {
                            Helper.CaptureRequirement(4939, @"[In FileIdBothDirectoryInformation] Pseudocode for the operation is as follows:
                                If OutputBufferSize is smaller than FieldOffset( FILE_ID_BOTH_DIR_INFORMATION.FileName ), 
                                the operation MUST be failed with STATUS_INFO_LENGTH_MISMATCH.");
                            return MessageStatus.INFO_LENGTH_MISMATCH;
                        }
                    case OutBufferSmall.FileIdFullDirectoryInformation:
                        {
                            return MessageStatus.INFO_LENGTH_MISMATCH;
                        }
                    case OutBufferSmall.FileNamesInformation:
                        {
                            Helper.CaptureRequirement(4983, @"[In FileNamesInformation] Pseudocode for the operation is as follows:
                                If OutputBufferSize is smaller than FieldOffset( FILE_NAMES_INFORMATION.FileName ), 
                                the operation MUST be failed with STATUS_INFO_LENGTH_MISMATCH.");
                            return MessageStatus.INFO_LENGTH_MISMATCH;
                        }
                    default:
                        break;
                }

                Helper.CaptureRequirement(4836, @"[In Directory Information Queries] Pseudocode for the algorithm is as follows:
                    If OutputBufferSize is less than the size needed to return a single entry, 
                    the operation MUST be failed with STATUS_INFO_LENGTH_MISMATCH.");
                return MessageStatus.INFO_LENGTH_MISMATCH;
            }

            if (fileNamePattern == FileNamePattern.Empty)
            {
                fileNamePattern = FileNamePattern.IndicateAll;
            }
            else
            {
                //If FileNamePattern is not a valid filename component as described in [MS-FSCC] section 2.1.5, with the exceptions that wildcard characters described in section 3.1.4.3 are permitted and the strings "." and ".." are permitted
                if (fileNamePattern == FileNamePattern.NotValidFilenameComponent)
                {
                    Helper.CaptureRequirement(849, @"[In Directory Information Queries ,Pseudocode for the algorithm is as follows: 
                        If Open.QueryPattern is empty] else [if FileNamePattern is not empty]If FileNamePattern is not a valid filename component 
                        as described in [MS-FSCC] section 2.1.5, with the exceptions that wildcard characters described in section 3.1.4.3 
                        are permitted and the strings \"".\"" and \""..\"" are permitted, the operation MUST be failed with STATUS_OBJECT_NAME_INVALID.");
                    return MessageStatus.OBJECT_NAME_INVALID;
                }
            }

            //If no records are being returned
            if (isNoRecordsReturned)
            {
                //If FirstQuery is true
                if (firstQuery)
                {
                    firstQuery = false;
                    Helper.CaptureRequirement(4875, @"[In Directory Information Queries,Pseudocode for the algorithm is as follows:]
                        If no records are being returned:If FirstQuery is TRUE:Set StatusToReturn to STATUS_NO_SUCH_FILE, which means no files were found 
                        in this directory that match the given wildcard pattern.");
                    returnStatus = MessageStatus.NO_SUCH_FILE;
                }
                else
                {
                    Helper.CaptureRequirement(4876, @"[In Directory Information Queries,Pseudocode for the algorithm is as follows:
                        If no records are being returned:] Else[If FirstQuery is FALSE]:Set StatusToReturn to STATUS_NO_MORE_FILES, 
                        which means no more files were found in this directory that match the given wildcard pattern.");
                    returnStatus = MessageStatus.NO_MORE_FILES;
                }
            }

            Helper.CaptureRequirement(865, @"[In Directory Information Queries,Pseudocode for the algorithm is as follows:Add a context,
                if the operation succeeds ]The object store MUST return:Status set to StatusToReturn.");
            return returnStatus;
        }
コード例 #28
0
        public static MessageStatus QueryFileReparsePointInformation(
            FileNamePattern fileNamePattern,
            QueryDirectoryScanType queryDirectoryScanType,
            QueryDirectoryFileNameMatchType queryDirectoryFileNameMatchType,
            QueryDirectoryOutputBufferType queryDirectoryOutputBufferType)
        {
            bool EmptyPattern = false;

            //If the object store does not implement this functionality, 
            //the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST
            if (!isImplementQueryFileReparsePointInformation)
            {
                Helper.CaptureRequirement(6276, @"[In FileReparsePointInformation]If the object store does not implement this functionality, 
                    the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST.");
                return MessageStatus.INVALID_DEVICE_REQUEST;
            }

            if (fileNamePattern == FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4)
            {
                Helper.CaptureRequirement(6280, @"[In FileReparsePointInformation]Pseudocode for the operation is as follows:
                    If FileNamePattern is not empty and FileNamePattern.Length (0 is a valid length) is not a multiple of 4, the operation 
                    MUST be failed with STATUS_INVALID_PARAMETER.");
                return MessageStatus.INVALID_PARAMETER;
            }

            if (fileNamePattern == FileNamePattern.Empty)
            {
                EmptyPattern = true;
            }
            else
            {
                EmptyPattern = false;
            }

            if ((queryDirectoryScanType == QueryDirectoryScanType.NotRestartScan) && 
                EmptyPattern &&
                (queryDirectoryFileNameMatchType == QueryDirectoryFileNameMatchType.FileNamePatternNotMatched))
            {
                Helper.CaptureRequirement(6286, @"[In FileReparsePointInformation]If RestartScan is FALSE and EmptyPattern is TRUE 
                    and there is no match, the operation MUST be failed with STATUS_NO_MORE_FILES.");
                return MessageStatus.NO_MORE_FILES;
            }

            if (!EmptyPattern 
                && (queryDirectoryFileNameMatchType == QueryDirectoryFileNameMatchType.FileNamePatternNotMatched))
            {
                Helper.CaptureRequirement(6287, @"[In FileReparsePointInformation]The operation MUST fail with STATUS_NO_SUCH_FILE under 
                    any of the following conditions:EmptyPattern is FALSE and there is no match.");
                return MessageStatus.NO_SUCH_FILE;
            }

            if (EmptyPattern && (queryDirectoryScanType == QueryDirectoryScanType.RestartScan) && 
                (queryDirectoryFileNameMatchType == QueryDirectoryFileNameMatchType.FileNamePatternNotMatched))
            {
                Helper.CaptureRequirement(6288, @"[In FileReparsePointInformation]The operation MUST fail with STATUS_NO_SUCH_FILE 
                    under any of the following conditions:EmptyPattern is TRUE and RestartScan is TRUE and there is no match.");
                return MessageStatus.NO_SUCH_FILE;
            }

            //If OutputBuffer is not large enough to hold the first matching entry
            if (queryDirectoryOutputBufferType == QueryDirectoryOutputBufferType.OutputBufferIsNotEnough)
            {
                Helper.CaptureRequirement(6289, @"[In FileReparsePointInformation]The operation MUST fail with STATUS_BUFFER_OVERFLOW 
                    if OutputBuffer is not large enough to hold the first matching entry.");
                return MessageStatus.INFO_LENGTH_MISMATCH;
            }

            //If there is at least one match, the operation is considered successful
            if (queryDirectoryFileNameMatchType == QueryDirectoryFileNameMatchType.FileNamePatternMatched)
            {
                Helper.CaptureRequirement(6290, @"[In FileReparsePointInformation]If there is at least one match, the operation is considered successful. 
                    The object store MUST return:[Status, OutputBuffer,ByteCount].");
                Helper.CaptureRequirement(6291, @"[In FileReparsePointInformation]Status set to STATUS_SUCCESS.");

                return MessageStatus.SUCCESS;
            }

            Helper.CaptureRequirement(6290, @"[In FileReparsePointInformation]If there is at least one match, the operation is considered successful. 
                The object store MUST return:[Status, OutputBuffer,ByteCount].");
            Helper.CaptureRequirement(6291, @"[In FileReparsePointInformation]Status set to STATUS_SUCCESS.");
            return MessageStatus.SUCCESS;
        }
コード例 #29
0
        private string GetTrackPath(TrackInfo track, string ext)
        {
            string file_path = null;

            if (track.HasAttribute(TrackMediaAttributes.Podcast))
            {
                string album = FileNamePattern.Escape(track.DisplayAlbumTitle);
                string title = FileNamePattern.Escape(track.DisplayTrackTitle);
                file_path = System.IO.Path.Combine("Podcasts", album);
                file_path = System.IO.Path.Combine(file_path, title);
            }
            else if (track.HasAttribute(TrackMediaAttributes.VideoStream))
            {
                string album = FileNamePattern.Escape(track.DisplayAlbumTitle);
                string title = FileNamePattern.Escape(track.DisplayTrackTitle);
                file_path = System.IO.Path.Combine(album, title);
            }
            else if (ms_device == null || !ms_device.GetTrackPath(track, out file_path))
            {
                // If the folder_depth property exists, we have to put the files in a hiearchy of
                // the exact given depth (not including the mount point/audio_folder).
                if (FolderDepth != -1)
                {
                    int    depth        = FolderDepth;
                    string album_artist = FileNamePattern.Escape(track.DisplayAlbumArtistName);
                    string track_album  = FileNamePattern.Escape(track.DisplayAlbumTitle);
                    string track_number = FileNamePattern.Escape(String.Format("{0:00}", track.TrackNumber));
                    string track_title  = FileNamePattern.Escape(track.DisplayTrackTitle);

                    if (depth == 0)
                    {
                        // Artist - Album - 01 - Title
                        string track_artist = FileNamePattern.Escape(track.DisplayArtistName);
                        file_path = String.Format("{0} - {1} - {2} - {3}", track_artist, track_album, track_number, track_title);
                    }
                    else if (depth == 1)
                    {
                        // Artist - Album/01 - Title
                        file_path = String.Format("{0} - {1}", album_artist, track_album);
                        file_path = System.IO.Path.Combine(file_path, String.Format("{0} - {1}", track_number, track_title));
                    }
                    else if (depth == 2)
                    {
                        // Artist/Album/01 - Title
                        file_path = album_artist;
                        file_path = System.IO.Path.Combine(file_path, track_album);
                        file_path = System.IO.Path.Combine(file_path, String.Format("{0} - {1}", track_number, track_title));
                    }
                    else
                    {
                        // If the *required* depth is more than 2..go nuts!
                        for (int i = 0; i < depth - 2; i++)
                        {
                            if (i == 0)
                            {
                                file_path = album_artist.Substring(0, Math.Min(i + 1, album_artist.Length)).Trim();
                            }
                            else
                            {
                                file_path = System.IO.Path.Combine(file_path, album_artist.Substring(0, Math.Min(i + 1, album_artist.Length)).Trim());
                            }
                        }

                        // Finally add on the Artist/Album/01 - Track
                        file_path = System.IO.Path.Combine(file_path, album_artist);
                        file_path = System.IO.Path.Combine(file_path, track_album);
                        file_path = System.IO.Path.Combine(file_path, String.Format("{0} - {1}", track_number, track_title));
                    }
                }
                else
                {
                    file_path = MusicLibrarySource.MusicFileNamePattern.CreateFromTrackInfo(track);
                }
            }

            if (track.HasAttribute(TrackMediaAttributes.VideoStream))
            {
                file_path = System.IO.Path.Combine(WritePathVideo, file_path);
            }
            else
            {
                file_path = System.IO.Path.Combine(WritePath, file_path);
            }
            file_path += ext;

            return(file_path);
        }
コード例 #30
0
        internal static MessageStatus WorkaroundQueryFileReparsePointInfo(FileSystem fileSystem, FileNamePattern fileNamePattern,
                                                                          bool restartScan,
                                                                          bool isDirectoryNotRight,
                                                                          bool isOutPutBufferNotEnough,
                                                                          MessageStatus returnedStatus,
                                                                          ITestSite site)
        {
            bool EmptyPattern = false;

            if (fileNamePattern == FileNamePattern.Empty)
            {
                EmptyPattern = true;
            }
            else
            {
                EmptyPattern = false;
            }

            if (fileSystem != FileSystem.NTFS)
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.INVALID_DEVICE_REQUEST, returnedStatus, site);
            }

            else if (fileNamePattern == FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4)
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.INVALID_PARAMETER, returnedStatus, site);
            }

            else if (!restartScan && EmptyPattern && isDirectoryNotRight)
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.NO_MORE_FILES, returnedStatus, site);
            }

            else if ((!EmptyPattern && isDirectoryNotRight) ||
                     (EmptyPattern && restartScan && isDirectoryNotRight))
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.NO_SUCH_FILE, returnedStatus, site);
            }

            else if (isOutPutBufferNotEnough)
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.INFO_LENGTH_MISMATCH, returnedStatus, site);
            }

            //If there is at least one match, the operation is considered successful
            else if (!isDirectoryNotRight)
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.SUCCESS, returnedStatus, site);
            }

            return(returnedStatus);
        }
コード例 #31
0
 internal static MessageStatus WorkaroundQueryDirectoryInfo(FileNamePattern fileNamePattern, bool isNoRecordsReturned, bool isOutBufferSizeLess, MessageStatus returnedStatus, ITestSite site)
 {
     if (isOutBufferSizeLess)
     {
         returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(4836, MessageStatus.INFO_LENGTH_MISMATCH, returnedStatus, site);
     }
     else if (fileNamePattern == FileNamePattern.NotValidFilenameComponent)
     {
         returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(849, MessageStatus.OBJECT_NAME_INVALID, returnedStatus, site);
     }
     else if (isNoRecordsReturned)
     {
         returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(865, MessageStatus.NO_SUCH_FILE, returnedStatus, site);
     }
     return returnedStatus;
 }
コード例 #32
0
        internal static MessageStatus WorkaroundQueryFileReparsePointInfo(FileSystem fileSystem, FileNamePattern fileNamePattern,
            bool restartScan,
            bool isDirectoryNotRight,
            bool isOutPutBufferNotEnough,
            MessageStatus returnedStatus,
            ITestSite site)
        {
            bool EmptyPattern = false;
            if (fileNamePattern == FileNamePattern.Empty)
            {
                EmptyPattern = true;
            }
            else
            {
                EmptyPattern = false;
            }

            if (fileSystem == FileSystem.REFS)
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.INVALID_DEVICE_REQUEST, returnedStatus, site);
            }

            else if (fileNamePattern == FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4)
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.INVALID_PARAMETER, returnedStatus, site);
            }

            else if (!restartScan && EmptyPattern && isDirectoryNotRight)
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.NO_MORE_FILES, returnedStatus, site);
            }

            else if ((!EmptyPattern && isDirectoryNotRight) ||
                (EmptyPattern && restartScan && isDirectoryNotRight))
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.NO_SUCH_FILE, returnedStatus, site);
            }

            else if (isOutPutBufferNotEnough)
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.INFO_LENGTH_MISMATCH, returnedStatus, site);
            }

            //If there is at least one match, the operation is considered successful
            else if (!isDirectoryNotRight)
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.SUCCESS, returnedStatus, site);
            }

            return returnedStatus;
        }
コード例 #33
0
        public static MessageStatus QueryFileObjectIdInfo(
            FileNamePattern fileNamePattern,
            QueryDirectoryScanType queryDirectoryScanType,
            QueryDirectoryFileNameMatchType queryDirectoryFileNameMatchType,
            QueryDirectoryOutputBufferType queryDirectoryOutputBufferType)
        {
            Condition.IsTrue(fileNamePattern == FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4 ||
                             fileNamePattern == FileNamePattern.Empty ||
                             fileNamePattern == FileNamePattern.NotEmpty);

            bool emptyPattern = false;

            if (!isImplementQueryFileObjectIdInformation)
            {
                Helper.CaptureRequirement(4817, @"[In FileObjectIdInformation ] If the object store does not implement this functionality, 
                    the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST.");
                return(MessageStatus.INVALID_DEVICE_REQUEST);
            }

            //If FileNamePattern is not empty and FileNamePattern.Length (0 is a valid length)
            //is not a multiple of 4
            if (fileNamePattern == FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4)
            {
                Helper.CaptureRequirement(819, @"[In FileObjectIdInformation,Pseudocode for the operation is as follows:] 
                    If FileNamePattern is not empty and FileNamePattern.Length (0 is a valid length) is not a multiple of 4, 
                    the operation MUST be failed with STATUS_INVALID_PARAMETER.");
                return(MessageStatus.INVALID_PARAMETER);
            }

            // If FileNamePattern is empty, then the object store MUST set EmptyPattern to
            // True; otherwise it MUST set EmptyPattern to FALSE.
            if (fileNamePattern == FileNamePattern.Empty)
            {
                emptyPattern = true;
            }
            else
            {
                emptyPattern = false;
            }

            // If RestartScan is FALSE and EmptyPattern is true and there is no match,
            //the operation MUST be failed with STATUS_NO_MORE_FILES.
            if ((queryDirectoryScanType == QueryDirectoryScanType.NotRestartScan) &&
                (emptyPattern) &&
                (queryDirectoryFileNameMatchType == QueryDirectoryFileNameMatchType.FileNamePatternNotMatched) &&
                queryDirectoryOutputBufferType != QueryDirectoryOutputBufferType.OutputBufferIsNotEnough)
            {
                Helper.CaptureRequirement(826, @"[In FileObjectIdInformation,Pseudocode for the operation is as follows:]
                    If RestartScan is FALSE and EmptyPattern is TRUE and there is no match[Any comparison where the ObjectId chunk is greater than 
                    or equal to the FileNamePattern.Buffer chunk], the operation MUST be failed with STATUS_NO_MORE_FILES.");
                return(MessageStatus.NO_MORE_FILES);
            }

            // EmptyPattern is FALSE and there is no match.
            if ((!emptyPattern) && (queryDirectoryFileNameMatchType == QueryDirectoryFileNameMatchType.FileNamePatternNotMatched) &&
                queryDirectoryOutputBufferType != QueryDirectoryOutputBufferType.OutputBufferIsNotEnough)
            {
                Helper.CaptureRequirement(828, @"[In FileObjectIdInformation,Pseudocode for the operation is as follows:]The operation MUST fail with 
                    STATUS_NO_SUCH_FILE under any of the following conditions:EmptyPattern is FALSE and there is no match
                    [the volume for Files having File.ObjectId matching FileNamePattern].");
                return(MessageStatus.NO_SUCH_FILE);
            }

            // EmptyPattern is true and RestartScan is true and there is no match.
            if ((emptyPattern) &&
                (queryDirectoryScanType == QueryDirectoryScanType.RestartScan) &&
                (queryDirectoryFileNameMatchType == QueryDirectoryFileNameMatchType.FileNamePatternNotMatched) &&
                queryDirectoryOutputBufferType != QueryDirectoryOutputBufferType.OutputBufferIsNotEnough)
            {
                Helper.CaptureRequirement(829, @"[In FileObjectIdInformation,Pseudocode for the operation is as follows:]The operation MUST fail with 
                    STATUS_NO_SUCH_FILE under any of the following conditions:EmptyPattern is TRUE and RestartScan is TRUE 
                    and there is no match[the volume for Files having File.ObjectId matching FileNamePattern].");
                return(MessageStatus.NO_SUCH_FILE);
            }

            //The operation MUST fail with STATUS_BUFFER_OVERFLOW if OutputBuffer is not large enough to hold the first matching entry.
            if (queryDirectoryOutputBufferType == QueryDirectoryOutputBufferType.OutputBufferIsNotEnough)
            {
                Helper.CaptureRequirement(830, @"[In FileObjectIdInformation,Pseudocode for the operation is as follows:]The operation MUST fail with 
                    STATUS_BUFFER_OVERFLOW if OutputBuffer is not large enough to hold the first matching entry.");
                return(MessageStatus.INFO_LENGTH_MISMATCH);
            }

            Helper.CaptureRequirement(813, @"[In Server Requests Querying a Directory]On completion, the object store MUST return:
                [Status,OutputBuffer,BytesReturned ].");
            Helper.CaptureRequirement(833, @"[In FileObjectIdInformation, Pseudocode for the operation is as follows:
                If there is at least one match]The object store MUST return:Status set to STATUS_SUCCESS.");
            return(MessageStatus.SUCCESS);
        }
コード例 #34
0
        public void DoWindowContents(Rect settingsRect)
        {
            if (DoMigrations)
            {
                if (!migratedOutputImageSettings)
                {
                    //Yes, I know for the people who used to use 1080 as scaling and have upgraded this will turn off scaling for them.
                    //Unfortunately I don't think there's a better way to handle this.
                    scaleOutputImage = outputImageFixedHeight > 0 && outputImageFixedHeight != DefaultOutputImageFixedHeight;
                    if (!scaleOutputImage)
                    {
                        outputImageFixedHeight = DefaultOutputImageFixedHeight;
                    }
                    migratedOutputImageSettings = true;
                    Log.Warning("Migrated output image settings");
                }
                if (!migratedInterval)
                {
                    whichInterval = RenderIntervalHelper.Intervals.IndexOf(interval);
                    if (whichInterval < 0)
                    {
                        whichInterval = RenderIntervalHelper.Intervals.IndexOf(DefaultInterval);
                    }
                    migratedInterval = true;
                    Log.Warning("Migrated interval settings");
                }
            }

            Listing_Standard ls = new Listing_Standard();
            var leftHalf        = new Rect(settingsRect.x, settingsRect.y, settingsRect.width / 2 - 12f, settingsRect.height);
            var rightHalf       = new Rect(settingsRect.x + settingsRect.width / 2 + 12f, settingsRect.y, settingsRect.width / 2 - 12f, settingsRect.height);

            ls.Begin(leftHalf);

            // Left half (general settings)
            ls.CheckboxLabeled("LPR_SettingsEnabledLabel".Translate(), ref enabled, "LPR_SettingsEnabledDescription".Translate());
            TextAnchor backupAnchor = Text.Anchor;

            Text.Anchor = TextAnchor.MiddleLeft;
            if (ls.ButtonTextLabeled("LPR_SettingsRenderFeedbackLabel".Translate(), ("LPR_RenderFeedback_" + renderFeedback).Translate()))
            {
                List <FloatMenuOption> menuEntries = new List <FloatMenuOption>();
                var feedbackTypes = (RenderFeedback[])Enum.GetValues(typeof(RenderFeedback));
                foreach (var type in feedbackTypes)
                {
                    menuEntries.Add(new FloatMenuOption(("LPR_RenderFeedback_" + EnumUtils.ToFriendlyString(type)).Translate(), delegate
                    {
                        renderFeedback = type;
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(menuEntries));
            }
            Text.Anchor = backupAnchor;

            ls.Gap();
            ls.Label("LPR_SettingsRenderSettingsLabel".Translate(), -1, "LPR_SettingsRenderSettingsDescription".Translate());
            ls.GapLine();
            ls.CheckboxLabeled("LPR_SettingsRenderDesignationsLabel".Translate(), ref renderDesignations, "LPR_SettingsRenderDesignationsDescription".Translate());
            ls.CheckboxLabeled("LPR_SettingsRenderThingIconsLabel".Translate(), ref renderThingIcons, "LPR_SettingsRenderThingIconsDescription".Translate());
            ls.CheckboxLabeled("LPR_SettingsRenderGameConditionsLabel".Translate(), ref renderGameConditions, "LPR_SettingsRenderGameConditionsDescription".Translate());
            ls.CheckboxLabeled("LPR_SettingsRenderWeatherLabel".Translate(), ref renderWeather, "LPR_SettingsRenderWeatherDescription".Translate());
            ls.GapLine();

            ls.Gap();
            ls.Label("LPR_SettingsSmoothRenderAreaStepsLabel".Translate() + smoothRenderAreaSteps.ToString(": #0"), -1, "LPR_SettingsSmoothRenderAreaStepsDescription".Translate());
            smoothRenderAreaSteps = (int)ls.Slider(smoothRenderAreaSteps, 0, 30);

            ls.Label($"{"LPR_SettingsIntervalLabel".Translate()} {RenderIntervalHelper.GetLabel(interval)}", -1, "LPR_SettingsIntervalDescription".Translate());
            whichInterval = (int)ls.Slider(whichInterval, 0, RenderIntervalHelper.Intervals.Count - 1);
            ls.Label("LPR_SettingsTimeOfDayLabel".Translate() + timeOfDay.ToString(" 00H"), -1, "LPR_SettingsTimeOfDayDescription".Translate());
            timeOfDay = (int)ls.Slider(timeOfDay, 0, 23);

            ls.End();

            // Right half (file settings)
            ls.Begin(rightHalf);

            backupAnchor = Text.Anchor;
            Text.Anchor  = TextAnchor.MiddleLeft;
            if (ls.ButtonTextLabeled("LPR_SettingsEncodingLabel".Translate(), ("LPR_ImgEncoding_" + EnumUtils.ToFriendlyString(encoding)).Translate()))
            {
                List <FloatMenuOption> menuEntries = new List <FloatMenuOption>();
                var encodingTypes = (EncodingType[])Enum.GetValues(typeof(EncodingType));
                foreach (var encodingType in encodingTypes)
                {
                    menuEntries.Add(new FloatMenuOption(("LPR_ImgEncoding_" + EnumUtils.ToFriendlyString(encodingType)).Translate(), delegate
                    {
                        encoding = encodingType;
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(menuEntries));
            }
            Text.Anchor = backupAnchor;

            if (encoding == EncodingType.UnityJPG)
            {
                ls.Label("LPR_JPGQualityLabel".Translate() + jpgQuality.ToString(": ##0"), -1, "LPR_JPGQualityDescription".Translate());
                jpgQuality = (int)ls.Slider(jpgQuality, 1, 100);
            }

            ls.Label("LPR_SettingsPixelPerCellLabel".Translate() + pixelPerCell.ToString(": ##0 pcc"), -1, "LPR_SettingsPixelPerCellDescription".Translate());
            pixelPerCell = (int)ls.Slider(pixelPerCell, 1, 64);

            ls.Gap();
            ls.CheckboxLabeled("LPR_SettingsScaleOutputImageLabel".Translate(), ref scaleOutputImage, "LPR_SettingsScaleOutputImageDescription".Translate());
            if (scaleOutputImage)
            {
                ls.Label("LPR_SettingsOutputImageFixedHeightLabel".Translate());
                ls.TextFieldNumeric(ref outputImageFixedHeight, ref outputImageFixedHeightBuffer, 1);
                ls.Gap();
            }

            ls.GapLine();
            if (scaleOutputImage)
            {
                ls.Gap(); // All about that visual balance
            }
            ls.Label("LPR_SettingsExportPathLabel".Translate(), -1, "LPR_SettingsExportPathDescription".Translate());
            exportPath = ls.TextEntry(exportPath);

            ls.Gap();
            ls.CheckboxLabeled("LPR_SettingsCreateSubdirsLabel".Translate(), ref createSubdirs, "LPR_SettingsCreateSubdirsDescription".Translate());
            backupAnchor = Text.Anchor;
            Text.Anchor  = TextAnchor.MiddleLeft;
            if (ls.ButtonTextLabeled("LPR_SettingsFileNamePatternLabel".Translate(), ("LPR_FileNamePattern_" + fileNamePattern).Translate()))
            {
                List <FloatMenuOption> menuEntries = new List <FloatMenuOption>();
                var patterns = (FileNamePattern[])Enum.GetValues(typeof(FileNamePattern));
                foreach (var pattern in patterns)
                {
                    menuEntries.Add(new FloatMenuOption(("LPR_FileNamePattern_" + EnumUtils.ToFriendlyString(pattern)).Translate(), delegate
                    {
                        fileNamePattern = pattern;
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(menuEntries));
            }
            Text.Anchor = backupAnchor;

            ls.End();
        }
コード例 #35
0
ファイル: Settings.cs プロジェクト: Goletas/screencapture
        public virtual void FromSettings(Settings source)
        {
            if (source == null)
            {
                throw new ArgumentNullException();
            }

            if (!ReferenceEquals(this, source))
            {
                this._FileType = source._FileType.Clone();
                this._ImageDestinations = source._ImageDestinations;
                this._WorkingDirectory = source._WorkingDirectory;
                this._AlwaysOnTop = source._AlwaysOnTop;
                this._AutoStartup = source._AutoStartup;
                this._UseExternalApp = source._UseExternalApp;
                this._ExternalApp = source._ExternalApp;
                this._UseFileOverwrite = source._UseFileOverwrite;
                this._IncludeCursor = source._IncludeCursor;
                this._FileNameFormat = source._FileNameFormat;
                this._FileNamePattern = source._FileNamePattern;
            }
        }
コード例 #36
0
        public static MessageStatus QueryFileObjectIdInfo(
            FileNamePattern fileNamePattern,
            QueryDirectoryScanType queryDirectoryScanType,
            QueryDirectoryFileNameMatchType queryDirectoryFileNameMatchType,
            QueryDirectoryOutputBufferType queryDirectoryOutputBufferType)
        {
            Condition.IsTrue(fileNamePattern == FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4 ||
                fileNamePattern == FileNamePattern.Empty ||
                fileNamePattern == FileNamePattern.NotEmpty);

            bool emptyPattern = false;

            if (!isImplementQueryFileObjectIdInformation)
            {
                Helper.CaptureRequirement(4817, @"[In FileObjectIdInformation ] If the object store does not implement this functionality, 
                    the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST.");
                return MessageStatus.INVALID_DEVICE_REQUEST;
            }

            //If FileNamePattern is not empty and FileNamePattern.Length (0 is a valid length) 
            //is not a multiple of 4
            if (fileNamePattern == FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4)
            {
                Helper.CaptureRequirement(819, @"[In FileObjectIdInformation,Pseudocode for the operation is as follows:] 
                    If FileNamePattern is not empty and FileNamePattern.Length (0 is a valid length) is not a multiple of 4, 
                    the operation MUST be failed with STATUS_INVALID_PARAMETER.");
                return MessageStatus.INVALID_PARAMETER;
            }

            // If FileNamePattern is empty, then the object store MUST set EmptyPattern to 
            // True; otherwise it MUST set EmptyPattern to FALSE.
            if (fileNamePattern == FileNamePattern.Empty)
            {
                emptyPattern = true;
            }
            else
            {
                emptyPattern = false;
            }

            // If RestartScan is FALSE and EmptyPattern is true and there is no match, 
            //the operation MUST be failed with STATUS_NO_MORE_FILES.
            if ((queryDirectoryScanType == QueryDirectoryScanType.NotRestartScan) && 
                (emptyPattern) &&
                (queryDirectoryFileNameMatchType == QueryDirectoryFileNameMatchType.FileNamePatternNotMatched) &&
                queryDirectoryOutputBufferType != QueryDirectoryOutputBufferType.OutputBufferIsNotEnough)
            {
                Helper.CaptureRequirement(826, @"[In FileObjectIdInformation,Pseudocode for the operation is as follows:]
                    If RestartScan is FALSE and EmptyPattern is TRUE and there is no match[Any comparison where the ObjectId chunk is greater than 
                    or equal to the FileNamePattern.Buffer chunk], the operation MUST be failed with STATUS_NO_MORE_FILES.");
                return MessageStatus.NO_MORE_FILES;
            }

            // EmptyPattern is FALSE and there is no match.
            if ((!emptyPattern) && (queryDirectoryFileNameMatchType == QueryDirectoryFileNameMatchType.FileNamePatternNotMatched) &&
                queryDirectoryOutputBufferType != QueryDirectoryOutputBufferType.OutputBufferIsNotEnough)
            {
                Helper.CaptureRequirement(828, @"[In FileObjectIdInformation,Pseudocode for the operation is as follows:]The operation MUST fail with 
                    STATUS_NO_SUCH_FILE under any of the following conditions:EmptyPattern is FALSE and there is no match
                    [the volume for Files having File.ObjectId matching FileNamePattern].");
                return MessageStatus.NO_SUCH_FILE;
            }

            // EmptyPattern is true and RestartScan is true and there is no match.
            if ((emptyPattern) && 
                (queryDirectoryScanType == QueryDirectoryScanType.RestartScan) &&
                (queryDirectoryFileNameMatchType == QueryDirectoryFileNameMatchType.FileNamePatternNotMatched) &&
                queryDirectoryOutputBufferType != QueryDirectoryOutputBufferType.OutputBufferIsNotEnough)
            {
                Helper.CaptureRequirement(829, @"[In FileObjectIdInformation,Pseudocode for the operation is as follows:]The operation MUST fail with 
                    STATUS_NO_SUCH_FILE under any of the following conditions:EmptyPattern is TRUE and RestartScan is TRUE 
                    and there is no match[the volume for Files having File.ObjectId matching FileNamePattern].");
                return MessageStatus.NO_SUCH_FILE;
            }

            //The operation MUST fail with STATUS_BUFFER_OVERFLOW if OutputBuffer is not large enough to hold the first matching entry.
            if (queryDirectoryOutputBufferType == QueryDirectoryOutputBufferType.OutputBufferIsNotEnough)
            {
                Helper.CaptureRequirement(830, @"[In FileObjectIdInformation,Pseudocode for the operation is as follows:]The operation MUST fail with 
                    STATUS_BUFFER_OVERFLOW if OutputBuffer is not large enough to hold the first matching entry.");
                return MessageStatus.INFO_LENGTH_MISMATCH;
            }
            
            Helper.CaptureRequirement(813, @"[In Server Requests Querying a Directory]On completion, the object store MUST return:
                [Status,OutputBuffer,BytesReturned ].");
            Helper.CaptureRequirement(833, @"[In FileObjectIdInformation, Pseudocode for the operation is as follows:
                If there is at least one match]The object store MUST return:Status set to STATUS_SUCCESS.");
            return MessageStatus.SUCCESS;
        }
コード例 #37
0
        internal static MessageStatus WorkaroundQueryFileObjectIdInfo(bool isObjectIDsSupported, FileNamePattern fileNamePattern,
            bool restartScan,
            bool isDirectoryNotRight,
            bool isOutPutBufferNotEnough,
            MessageStatus returnedStatus,
            ITestSite site)
        {
            if (!isObjectIDsSupported)
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.INVALID_DEVICE_REQUEST, returnedStatus, site);
            }
            else if (fileNamePattern != FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4 &&
                restartScan && !isDirectoryNotRight && !isOutPutBufferNotEnough)
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.SUCCESS, returnedStatus, site);
            }
            else if ((!restartScan) && (fileNamePattern == FileNamePattern.Empty) && (isDirectoryNotRight))
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.NO_MORE_FILES, returnedStatus, site);
            }

            else if ((fileNamePattern == FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4)
                && (isDirectoryNotRight)
                && (!isOutPutBufferNotEnough))
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.INVALID_PARAMETER, returnedStatus, site);
            }

            // EmptyPattern is FALSE and there is no match.
            else if ((!(fileNamePattern == FileNamePattern.Empty)) && (isDirectoryNotRight))
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.NO_SUCH_FILE, returnedStatus, site);
            }

            // EmptyPattern is true and RestartScan is false and there is no match and output Buffer is not enough.
            else if ((fileNamePattern == FileNamePattern.Empty)
                && (!restartScan)
                && (!isDirectoryNotRight)
                && (!isOutPutBufferNotEnough))
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.SUCCESS, returnedStatus, site);
            }

            // EmptyPattern is true and RestartScan is true and there is no match.
            else if ((fileNamePattern == FileNamePattern.Empty) && (restartScan) && (isDirectoryNotRight) && (!isOutPutBufferNotEnough))
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.NO_SUCH_FILE, returnedStatus, site);
            }

            else if (isOutPutBufferNotEnough)
            {
                returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(830, MessageStatus.INFO_LENGTH_MISMATCH, returnedStatus, site);
            }

            return returnedStatus;
        }
コード例 #38
0
        internal static MessageStatus WorkaroundQueryFileObjectIdInfo(bool isObjectIDsSupported, FileNamePattern fileNamePattern,
                                                                      bool restartScan,
                                                                      bool isDirectoryNotRight,
                                                                      bool isOutPutBufferNotEnough,
                                                                      MessageStatus returnedStatus,
                                                                      ITestSite site)
        {
            if (!isObjectIDsSupported)
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.INVALID_DEVICE_REQUEST, returnedStatus, site);
            }
            else if (fileNamePattern != FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4 &&
                     restartScan && !isDirectoryNotRight && !isOutPutBufferNotEnough)
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.SUCCESS, returnedStatus, site);
            }
            else if ((!restartScan) && (fileNamePattern == FileNamePattern.Empty) && (isDirectoryNotRight))
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.NO_MORE_FILES, returnedStatus, site);
            }

            else if ((fileNamePattern == FileNamePattern.NotEmpty_LengthIsNotAMultipleOf4) &&
                     (isDirectoryNotRight) &&
                     (!isOutPutBufferNotEnough))
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.INVALID_PARAMETER, returnedStatus, site);
            }

            // EmptyPattern is FALSE and there is no match.
            else if ((!(fileNamePattern == FileNamePattern.Empty)) && (isDirectoryNotRight))
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.NO_SUCH_FILE, returnedStatus, site);
            }

            // EmptyPattern is true and RestartScan is false and there is no match and output Buffer is not enough.
            else if ((fileNamePattern == FileNamePattern.Empty) &&
                     (!restartScan) &&
                     (!isDirectoryNotRight) &&
                     (!isOutPutBufferNotEnough))
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.SUCCESS, returnedStatus, site);
            }

            // EmptyPattern is true and RestartScan is true and there is no match.
            else if ((fileNamePattern == FileNamePattern.Empty) && (restartScan) && (isDirectoryNotRight) && (!isOutPutBufferNotEnough))
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.NO_SUCH_FILE, returnedStatus, site);
            }

            else if (isOutPutBufferNotEnough)
            {
                returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(830, MessageStatus.INFO_LENGTH_MISMATCH, returnedStatus, site);
            }

            return(returnedStatus);
        }