Beispiel #1
0
        /// <inheritdoc/>
        public IEnumerable <FileStatistics> GetDirectoryListing(string remotePath)
        {
            Collection <FileStatistics> value = new Collection <FileStatistics>();

            // create the stat request message.
            this.Socket.SendSyncRequest(SyncCommand.LIST, remotePath);

            while (true)
            {
                var response = this.Socket.ReadSyncResponse();

                if (response == SyncCommand.DONE)
                {
                    break;
                }
                else if (response != SyncCommand.DENT)
                {
                    throw new AdbException($"The server returned an invalid sync response.");
                }

                FileStatistics entry = new FileStatistics();
                this.ReadStatistics(entry);
                entry.Path = this.Socket.ReadSyncString();

                value.Add(entry);
            }

            return(value);
        }
Beispiel #2
0
        private void ReadStatistics(FileStatistics value)
        {
            byte[] statResult = new byte[12];
            this.Socket.Read(statResult);

            if (!BitConverter.IsLittleEndian)
            {
                Array.Reverse(statResult, 0, 4);
                Array.Reverse(statResult, 4, 4);
                Array.Reverse(statResult, 8, 4);
            }

            value.FileMode = (UnixFileMode)BitConverter.ToInt32(statResult, 0);
            value.Size     = BitConverter.ToInt32(statResult, 4);
            value.Time     = DateTimeOffset.FromUnixTimeSeconds(BitConverter.ToInt32(statResult, 8));
        }
Beispiel #3
0
        /// <include file='.\ISyncService.xml' path='/SyncService/Stat/*'/>
        public FileStatistics Stat(string remotePath)
        {
            // create the stat request message.
            this.Socket.SendSyncRequest(SyncCommand.STAT, remotePath);

            // read the result, in a byte array containing 3 ints
            // (mode, size, time)
            var statv2 = new Stat2();

            statv2.ReadFrom(this.Socket);
            if (statv2.Command != SyncCommand.STAT)
            {
                throw new AdbException($"The server returned an invalid sync response.");
            }

            FileStatistics value = FileStatistics.ReadFromStat2(remotePath, statv2);

            return(value);
        }
Beispiel #4
0
        /// <inheritdoc/>
        public FileStatistics Stat(string remotePath)
        {
            // create the stat request message.
            this.Socket.SendSyncRequest(SyncCommand.STAT, remotePath);

            if (this.Socket.ReadSyncResponse() != SyncCommand.STAT)
            {
                throw new AdbException($"The server returned an invalid sync response.");
            }

            // read the result, in a byte array containing 3 ints
            // (mode, size, time)
            FileStatistics value = new FileStatistics();

            value.Path = remotePath;

            this.ReadStatistics(value);

            return(value);
        }
        private void ReadStatistics(FileStatistics value)
        {
            byte[] statResult = new byte[12];
            this.Socket.Read(statResult);

            if (!BitConverter.IsLittleEndian)
            {
                Array.Reverse(statResult, 0, 4);
                Array.Reverse(statResult, 4, 4);
                Array.Reverse(statResult, 8, 4);
            }

            value.FileMode = (UnixFileMode)BitConverter.ToInt32(statResult, 0);
            value.Size = BitConverter.ToInt32(statResult, 4);
            value.Time = DateTimeHelper.Epoch.AddSeconds(BitConverter.ToInt32(statResult, 8)).ToLocalTime();
        }
        /// <include file='.\ISyncService.xml' path='/SyncService/GetDirectoryListing/*'/>
        public IEnumerable<FileStatistics> GetDirectoryListing(string remotePath)
        {
            Collection<FileStatistics> value = new Collection<FileStatistics>();

            // create the stat request message.
            this.Socket.SendSyncRequest(SyncCommand.LIST, remotePath);

            while (true)
            {
                var response = this.Socket.ReadSyncResponse();
                FileStatistics entry = new FileStatistics();
                this.ReadStatistics(entry);

                var length = this.Socket.ReadSyncLength();

                if (response == SyncCommand.DONE)
                {
                    break;
                }
                else if (response != SyncCommand.DENT)
                {
                    throw new AdbException($"The server returned an invalid sync response.");
                }

                entry.Path = this.Socket.ReadSyncString(length);

                value.Add(entry);
            }

            return value;
        }
        /// <include file='.\ISyncService.xml' path='/SyncService/Stat/*'/>
        public FileStatistics Stat(string remotePath)
        {
            // create the stat request message.
            this.Socket.SendSyncRequest(SyncCommand.STAT, remotePath);

            if (this.Socket.ReadSyncResponse() != SyncCommand.STAT)
            {
                throw new AdbException($"The server returned an invalid sync response.");
            }

            // read the result, in a byte array containing 3 ints
            // (mode, size, time)
            FileStatistics value = new FileStatistics();
            value.Path = remotePath;

            this.ReadStatistics(value);

            return value;
        }