open() public abstract method

public abstract open ( string path ) : Stream
path string
return Stream
コード例 #1
0
 private bool DownloadLooseObject(AnyObjectId id, string looseName, WalkRemoteObjectDatabase remote)
 {
     try
     {
         byte[] compressed = remote.open(looseName).toArray();
         VerifyLooseObject(id, compressed);
         SaveLooseObject(id, compressed);
         return(true);
     }
     catch (FileNotFoundException e)
     {
         RecordError(id, e);
         return(false);
     }
     catch (IOException e)
     {
         throw new TransportException("Cannot download " + id.Name, e);
     }
 }
コード例 #2
0
 private bool DownloadLooseObject(AnyObjectId id, string looseName, WalkRemoteObjectDatabase remote)
 {
     try
     {
         byte[] compressed = remote.open(looseName).toArray();
         VerifyLooseObject(id, compressed);
         SaveLooseObject(id, compressed);
         return(true);
     }
     catch (FileNotFoundException e)
     {
         // Not available in a loose format from this alternate?
         // Try another strategy to get the object.
         //
         RecordError(id, e);
         return(false);
     }
     catch (IOException e)
     {
         throw new TransportException("Cannot download " + id.Name, e);
     }
 }
コード例 #3
0
 private bool DownloadLooseObject(AnyObjectId id, string looseName, WalkRemoteObjectDatabase remote)
 {
     try
     {
         byte[] compressed = remote.open(looseName).toArray();
         VerifyLooseObject(id, compressed);
         SaveLooseObject(id, compressed);
         return true;
     }
     catch (FileNotFoundException e)
     {
         RecordError(id, e);
         return false;
     }
     catch (IOException e)
     {
         throw new TransportException("Cannot download " + id.Name, e);
     }
 }
コード例 #4
0
            public void OpenIndex(ProgressMonitor pm)
            {
                if (Index != null)
                {
                    return;
                }

                if (TmpIdx.IsFile())
                {
                    try
                    {
                        Index = PackIndex.Open(TmpIdx);
                        return;
                    }
                    catch (FileNotFoundException)
                    {
                        // Fall through and get the file.
                    }
                }

                using (Stream s = _connection.open("pack/" + _idxName))
                {
                    pm.BeginTask("Get " + _idxName.Slice(0, 12) + "..idx", !s.CanSeek ? ProgressMonitor.UNKNOWN : (int)(s.Length / 1024));

                    try
                    {
                        using (var fos = new FileStream(TmpIdx.FullName, System.IO.FileMode.CreateNew, FileAccess.Write))
                        {
                            var buf = new byte[2048];
                            int cnt;
                            while (!pm.IsCancelled && (cnt = s.Read(buf, 0, buf.Length)) > 0)
                            {
                                fos.Write(buf, 0, cnt);
                                pm.Update(cnt / 1024);
                            }
                        }
                    }
                    catch (IOException)
                    {
                        TmpIdx.DeleteFile();
                        throw;
                    }
                }

                pm.EndTask();

                if (pm.IsCancelled)
                {
                    TmpIdx.DeleteFile();
                    return;
                }

                try
                {
                    Index = PackIndex.Open(TmpIdx);
                }
                catch (IOException)
                {
                    TmpIdx.DeleteFile();
                    throw;
                }
            }
コード例 #5
0
            public void OpenIndex(ProgressMonitor pm)
            {
                if (Index != null)
                {
                    return;
                }

                try
                {
                    Index = PackIndex.Open(TmpIdx);
                    return;
                }
                catch (FileNotFoundException)
                {
                }

                Stream s = _connection.open("pack/" + _idxName);

                pm.BeginTask("Get " + _idxName.Slice(0, 12) + "..idx", s.Length < 0 ? -1 : (int)(s.Length / 1024));
                try
                {
                    var fos = new FileStream(TmpIdx.ToString(), System.IO.FileMode.Open, FileAccess.ReadWrite);
                    try
                    {
                        var buf = new byte[2048];
                        int cnt;
                        while (!pm.IsCancelled && (cnt = s.Read(buf, 0, buf.Length)) >= 0)
                        {
                            fos.Write(buf, 0, cnt);
                            pm.Update(cnt / 1024);
                        }
                    }
                    finally
                    {
                        fos.Close();
                    }
                }
                catch (IOException)
                {
                    TmpIdx.Delete();
                    throw;
                }
                finally
                {
                    s.Close();
                }
                pm.EndTask();

                if (pm.IsCancelled)
                {
                    TmpIdx.Delete();
                    return;
                }

                try
                {
                    Index = PackIndex.Open(TmpIdx);
                }
                catch (IOException)
                {
                    TmpIdx.Delete();
                    throw;
                }
            }
コード例 #6
0
 private bool DownloadLooseObject(AnyObjectId id, string looseName, WalkRemoteObjectDatabase remote)
 {
     try
     {
         byte[] compressed = remote.open(looseName).toArray();
         VerifyLooseObject(id, compressed);
         SaveLooseObject(id, compressed);
         return true;
     }
     catch (FileNotFoundException e)
     {
         // Not available in a loose format from this alternate?
         // Try another strategy to get the object.
         //
         RecordError(id, e);
         return false;
     }
     catch (IOException e)
     {
         throw new TransportException("Cannot download " + id.Name, e);
     }
 }