public HResult GetPlaceholderInfoCallback(
            int commandId,
            string relativePath,
            uint triggeringProcessId,
            string triggeringProcessImageFileName)
        {
            Console.WriteLine($"GetPlaceholderInfoCallback: `{relativePath}`");

            ProjectedFileInfo fileInfo = this.GetFileInfo(relativePath);

            if (fileInfo == null)
            {
                return(HResult.FileNotFound);
            }

            DateTime now    = DateTime.UtcNow;
            HResult  result = this.virtualizationInstance.WritePlaceholderInfo(
                Path.Combine(Path.GetDirectoryName(relativePath), fileInfo.Name),
                creationTime: now,
                lastAccessTime: now,
                lastWriteTime: now,
                changeTime: now,
                fileAttributes: fileInfo.IsDirectory ? FileAttributes.Directory : FileAttributes.Archive,
                endOfFile: fileInfo.Size,
                isDirectory: fileInfo.IsDirectory,
                contentId: new byte[] { 0 },
                providerId: new byte[] { 1 });

            if (result != HResult.Ok)
            {
                Console.WriteLine("WritePlaceholderInformation failed: " + result);
            }

            return(result);
        }
Пример #2
0
            // Combination of the logic in List<T>.Enumerator MoveNext() and MoveNextRare()
            // https://github.com/dotnet/corefx/blob/b492409b4a1952cda4b078f800499d382e1765fc/src/Common/src/CoreLib/System/Collections/Generic/List.cs#L1137
            // (No need to check list._version as GVFS does not modify the lists used for enumeration)
            public bool MoveNext()
            {
                if (this.index < this.list.Count)
                {
                    this.Current = this.list[this.index];
                    this.index++;
                    return(true);
                }

                this.index   = this.list.Count + 1;
                this.Current = null;
                return(false);
            }
Пример #3
0
        private HResult GetDirectoryEnumeration(
            Guid enumerationId,
            string filterFileName,
            bool restartScan,
            DirectoryEnumerationResults results)
        {
            Console.WriteLine($"GetDiretoryEnumeration: {enumerationId}, {filterFileName}");

            try
            {
                ActiveEnumeration activeEnumeration = null;
                if (!this.activeEnumerations.TryGetValue(enumerationId, out activeEnumeration))
                {
                    return(HResult.InternalError);
                }

                if (restartScan)
                {
                    activeEnumeration.RestartEnumeration(filterFileName);
                }
                else
                {
                    activeEnumeration.TrySaveFilterString(filterFileName);
                }

                bool entryAdded = false;

                HResult result = HResult.Ok;
                while (activeEnumeration.IsCurrentValid)
                {
                    ProjectedFileInfo fileInfo = activeEnumeration.Current;

                    DateTime now = DateTime.UtcNow;
                    result = results.Add(
                        fileName: fileInfo.Name,
                        fileSize: (ulong)(fileInfo.IsDirectory ? 0 : fileInfo.Size),
                        isDirectory: fileInfo.IsDirectory,
                        fileAttributes: fileInfo.IsDirectory ? (uint)FileAttributes.Directory : (uint)FileAttributes.Archive,
                        creationTime: now,
                        lastAccessTime: now,
                        lastWriteTime: now,
                        changeTime: now);

                    if (result == HResult.Ok)
                    {
                        entryAdded = true;
                        activeEnumeration.MoveNext();
                    }
                    else
                    {
                        if (result == HResult.InsufficientBuffer)
                        {
                            if (entryAdded)
                            {
                                result = HResult.Ok;
                            }
                        }

                        break;
                    }
                }

                return(result);
            }
            catch (Win32Exception e)
            {
                return(HResultFromWin32(e.NativeErrorCode));
            }
            catch (Exception)
            {
                return(HResult.InternalError);
            }
        }
Пример #4
0
 public void Reset()
 {
     this.index   = 0;
     this.Current = null;
 }