예제 #1
0
        public void Notify(object sender, IO.FileSystemEventArgs args)
        {
            char separator       = IO.Path.DirectorySeparatorChar;
            string relative_path = args.FullPath.Substring (Path.Length);
            relative_path        = relative_path.Trim (new char [] {' ', separator});

            // Ignore changes that happened in the parent path
            if (!relative_path.Contains (separator.ToString ()))
                return;

            string repo_name = relative_path.Substring (0, relative_path.IndexOf (separator));

            foreach (SparkleRepoBase repo in ReposToNotify) {
                if (repo.Name.Equals (repo_name) && !repo.IsBuffering &&
                    (repo.Status != SyncStatus.SyncUp && repo.Status != SyncStatus.SyncDown)) {

                    Thread thread = new Thread (
                        new ThreadStart (delegate {
                            repo.OnFileActivity (args);
                        })
                    );

                    thread.Start ();
                }
            }
        }
        public override ShapeBase ReadShape(IO.TextReader TReader)
        {
            var Reader = new IO.TextReaderWE(TReader);
            var Shapes = new ShapeCollection() { Name = "Parts" };

            var Lines = new List<Line>();

            while (!Reader.IsFinished)
            {
                Line L;
                PointF P1, P2;

                if (Reader.ReadLine().Trim() != "zone")
                {
                    throw new Exception("Invalid output");
                }

                var t = new String[] { " " };
                var PS = Reader.ReadLine().Split(t, StringSplitOptions.RemoveEmptyEntries);
                P1 = new PointF(Single.Parse(PS[0]), Single.Parse(PS[1]));
                PS = Reader.ReadLine().Split(t, StringSplitOptions.RemoveEmptyEntries);
                P2 = new PointF(Single.Parse(PS[0]), Single.Parse(PS[1]));
                L = new Line(P1, P2);
                Lines.Add(L);
            }

            Shapes.Shapes.Add(new LinesShape(Lines) { Name = "Part 1" });

            return Shapes;
        }
예제 #3
0
파일: PackFile.cs 프로젝트: Pctg-x8/Altseed
        public IEnumerable<string> EnumerateFiles(string directoryPath, string searchPattern, IO.SearchOption searchOption)
        {
            if (directoryPath == null)
                throw new ArgumentNullException("directoryPath");
            if (searchPattern == null)
                throw new ArgumentNullException("searchPattern");
            if (HaveFile(directoryPath))
                throw new IO.IOException("ファイル名は指定できません");
            if (searchPattern.Contains(IO.Path.AltDirectorySeparatorChar) || searchPattern.Contains(IO.Path.DirectorySeparatorChar))
                throw new ArgumentException("searchPattern");

            string lowerDirectoryPath = directoryPath.ToLower();
            var regex = new System.Text.RegularExpressions.Regex(searchPattern.TrimEnd(TrimEndChars).Replace("?", @".").Replace("*", @".*") + "$");

            switch (searchOption)
            {
                case System.IO.SearchOption.AllDirectories:
                    return InternalHeader.Keys
                        .Where(key => key.StartsWith(lowerDirectoryPath))
                        .Where(key => regex.IsMatch(IO.Path.GetFileName(key)));
                case System.IO.SearchOption.TopDirectoryOnly:
                    return InternalHeader.Keys
                        .Where(key => key.StartsWith(lowerDirectoryPath))
                        .Where(key => !key.Substring(lowerDirectoryPath.Length).Contains(IO.Path.PathSeparator))
                        .Where(key => regex.IsMatch(IO.Path.GetFileName(key)));
                default:
                    throw new ArgumentException("searchOption");
            }
        }
예제 #4
0
 public static void Dispose(IO::FileStream aThis, bool disposing,
     [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
 {
     if (disposing)
     {
         innerStream.Dispose();
     }
 }
예제 #5
0
파일: streams.cs 프로젝트: bsv798/p3fes
        //private static Streams OpenStream<T>() where T : sio.Stream, new()
        //{
        //    Streams str = new Streams();

        //    str.str = new T();

        //    return str;
        //}

        private static BaseStreams OpenFileStream(string fileName, sio.FileAccess access, sio.FileMode mode)
        {
            BaseStreams str = new BaseStreams();

            str.str = new sio.FileStream(fileName, mode, access);

            return str;
        }
예제 #6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="stream">The stream </param>
        public StreamWriter(IO.Stream stream)
        {
            if (stream == null)
                throw new ArgumentNullException("stream", "The given stream must not be null.");
            if (!stream.CanWrite)
                throw new ArgumentException("The given stream must be writable.", "stream");

            this.stream = new IO.StreamWriter(stream);
        }
예제 #7
0
 private static IEnumerable<string> EnumerateFileSystemEntries(string path, IO::SearchOption option, CancellationToken token, IProgress<double> iprogress, bool isEnumFiles, bool isEnumDirs, double progress, double step)
 {
     if(iprogress != null) {
         iprogress.Report(progress);
     }
     if(isEnumFiles){
         IEnumerable<string> files = null;
         try{
             files = IO::Directory.EnumerateFiles(path);
         }catch(IO::IOException){
         }catch(UnauthorizedAccessException){
         }
         if(files != null){
             foreach(var file in files) {
                 yield return file;
             }
         }
     }
     if(option == IO::SearchOption.AllDirectories){
         string[] dirs = null;
         try{
             dirs = IO::Directory.EnumerateDirectories(path).ToArray();
         }catch(IO::IOException){
         }catch(UnauthorizedAccessException){
         }
         if(dirs != null){
             if(isEnumDirs){
                 foreach(var dir in dirs) {
                     yield return dir;
                 }
             }
             var stepE = step / dirs.Length;
             for(int i = 0; i < dirs.Length; i++){
                 var prog = progress + (step * i * stepE);
                 foreach(var subfiles in EnumerateFileSystemEntries(dirs[i], option, token, iprogress, isEnumFiles, isEnumDirs, prog, stepE)){
                     yield return subfiles;
                 }
             }
         }
     }else if(isEnumDirs){
         IEnumerable<string> dirsQ = null;
         try{
             dirsQ = IO::Directory.EnumerateDirectories(path);
         }catch(IO::IOException){
         }catch(UnauthorizedAccessException){
         }
         if(dirsQ != null){
             if(iprogress != null){
                 iprogress.Report(progress + step);
             }
             foreach(var dir in dirsQ) {
                 yield return dir;
             }
         }
     }
 }
예제 #8
0
 private static FileMode GetFileMode(IO.FileMode mode)
 {
     if (mode != IO.FileMode.Append)
     {
         return (FileMode)(int)mode;
     }
     else
     {
         return (FileMode)(int)IO.FileMode.OpenOrCreate;
     }
 }
예제 #9
0
파일: iso.cs 프로젝트: bsv798/p3fes
        public FileDirectoryDescriptor(sio.FileStream fs)
        {
            int i;

            hdr = misc.ReadStruct<Header>(fs);
            name = fs.ReadString(hdr.lenFilId);
            isDirectory = (hdr.filFlags & 2) == 2;
            if (!isDirectory)
                if ((i = name.LastIndexOf(';')) > -1)
                    name = name.Remove(i, name.Length - i);

            for (i = DefaultSize + hdr.lenFilId; i < hdr.lenDirRec; i++) //skip 'System use' field
                fs.ReadByte();
        }
예제 #10
0
        public override void WriteShape(ShapeBase Shape, IO.TextWriter Writer)
        {
            var Dic = new Dictionary<PointF, Int32>();
            var Sz = 0;

            ShapeWalker.Instance.TypedWalk<LinesShape>(Shape, S => { Sz++; });
            Writer.WriteLine(Sz);
            ShapeWalker.Instance.TypedWalk<LinesShape>(Shape, S => { Writer.WriteLine(S.Lines.Count); });

            Sz = 0;
            ShapeWalker.Instance.TypedWalk<LinesShape>(Shape,
                S =>
                {
                    foreach (var L in S.Lines)
                    {
                        if (!Dic.ContainsKey(L.P1))
                        {
                            Dic.Add(L.P1, Sz++);
                        }
                        if (!Dic.ContainsKey(L.P2))
                        {
                            Dic.Add(L.P2, Sz++);
                        }
                    }
                });

            Writer.WriteLine(Sz);
            foreach (var KV in Dic.OrderBy(KV => KV.Value))
            {
                Writer.Write(KV.Key.X);
                Writer.Write(" ");
                Writer.Write(KV.Key.Y);
                Writer.WriteLine();
            }

            ShapeWalker.Instance.TypedWalk<LinesShape>(Shape,
                S =>
                {
                    Writer.WriteLine();
                    foreach (var l in S.Lines)
                    {
                        Writer.Write(Dic[l.P1]);
                        Writer.Write(" ");
                        Writer.Write(Dic[l.P2]);
                        Writer.WriteLine();
                    }
                });
        }
예제 #11
0
		/// <summary>
		/// Entry point of the application.
		/// </summary>
		/// <param name="args">The command line arguments that have been specified.</param>
		public static int Main(string[] args)
		{
			var watch = Stopwatch.StartNew();

			PopulateParameters(args);

			var currentDirectory = Environment.CurrentDirectory;

			// If we're not in the correct app domain, set up a new app domain to run in 
			if (!newDomain)
			{
				int result = 0;
				foreach (var assembly in assemblies)
				{
					var fullAssemblyPath = Path.Combine(currentDirectory, assembly);
					var setupInfo = new AppDomainSetup
					                	{
					                		ApplicationBase = Path.Combine(currentDirectory, Path.GetDirectoryName(assembly)),
					                		PrivateBinPath = fullAssemblyPath,
					                		ConfigurationFile = fullAssemblyPath + ".config",
					                	};

					var domain = AppDomain.CreateDomain("ParallelTestsDomain", null, setupInfo);

					// Execute this program in the new application domain.  We HAVE to run in the 
					// new domain so we'll have the correct app.config and all the tests will be running in 
					// the correct context. 
					var newArgs = new[] {SwitchInNewDomain, fullAssemblyPath, outputXmlPath != null ? "/xml " + outputXmlPath : ""};
					result |= domain.ExecuteAssembly(Assembly.GetExecutingAssembly().Location, newArgs);
				}
				return result;
			}
			else
			{
				var assemblyPath = assemblies.First();
				Console.WriteLine("Running tests from {0}", assemblyPath);

				// as we're running in the correct domain, just run the tests. 
				var runner = new Runner();
				bool noErrors = runner.RunTests(assemblyPath, outputXmlPath);

				Console.WriteLine("Completed tests in: {0}", watch.Elapsed);
				return noErrors ? 0 : 1;
			}
		}
예제 #12
0
			/// <summary>Seeks to the specified offset. Origin is always Current, Begin and End are ignored.</summary>
			/// <param name="offset">Offset to seek to</param>
			/// <param name="origin">Origin. Always System.IO.SeekOrigin.Current</param>
			/// <returns>New position, meaningless in a circularbuffer</returns>
			public override long Seek(long offset, IO.SeekOrigin origin)
			{
				lock (this.buffer)
				{
					if (this.buffer.readPosition + offset >= this.buffer.internalData.Length)
					{
						this.buffer.readPosition = (this.buffer.readPosition + offset) % this.buffer.internalData.Length;
					}
					else if (this.buffer.readPosition + offset < 0)
					{
						this.buffer.readPosition = this.buffer.internalData.Length + this.buffer.readPosition + offset;
					}
					else
						this.buffer.readPosition += offset;
					
					return this.buffer.readPosition;
				}
			}
예제 #13
0
        internal static IO.FileStream Open(string path, IO.FileAccess access, IO.FileMode mode, IO.FileShare share = IO.FileShare.None, bool throwException = true)
        {
            var fileHandle = CreateFile(path, GetFileAccess(access), GetFileShare(share), default(IntPtr), GetFileMode(mode));

            if (fileHandle.IsInvalid)
            {
                if (throwException)
                {
                    HandleCOMError(Marshal.GetLastWin32Error());
                }
                else
                {
                    return null;
                }
            }

            return new IO.FileStream(fileHandle, access);
        }
        public override void WriteShape(ShapeBase Shape, IO.TextWriter Writer)
        {
            ShapeWalker.Instance.TypedWalk<LinesShape>(Shape,
                S =>
                {
                    foreach (var l in S.Lines)
                    {
                        Writer.WriteLine(" zone");

                        Writer.Write(l.P1.X);
                        Writer.Write(" ");
                        Writer.Write(l.P1.Y);
                        Writer.WriteLine();

                        Writer.Write(l.P2.X);
                        Writer.Write(" ");
                        Writer.Write(l.P2.Y);
                        Writer.WriteLine();
                    }
                });
        }
예제 #15
0
        public override ShapeBase ReadShape(IO.TextReader Reader)
        {
            int n = int.Parse(Reader.ReadLine().Trim());
            var ar = new int[n];
            for (int i = 0; i < n; i++)
            {
                ar[i] = int.Parse(Reader.ReadLine().Trim());
            }
            int m = int.Parse(Reader.ReadLine().Trim());

            var Points = new PointF[m];

            for (int i = 0; i < m; i++)
            {
                var L = Reader.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                Points[i] = new PointF(Single.Parse(L[0]), Single.Parse(L[1]));
            }

            var Collection = new ShapeCollection() { Name = "Parts" };

            var MyColors = new Color[] { Color.Red, Color.Blue, Color.Magenta, Color.Green, Color.Teal };

            for (int i = 0; i < n; i++)
            {
                m = ar[i];
                var S = new List<Line>();

                for (int j = 0; j < m; j++)
                {
                    var L = Reader.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    S.Add(new Line(Points[int.Parse(L[0]) - 1], Points[int.Parse(L[1]) - 1]));
                }

                Collection.Shapes.Add(new LinesShape(S) { Color = MyColors[i], Name = "Part " + (i + 1).ToString() });
            }

            return Collection;
        }
예제 #16
0
 public static void SetLength(IO::FileStream aThis, long aLength,
     [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
 {
     innerStream.SetLength(aLength);
 }
예제 #17
0
 public static long get_Length(IO::FileStream aThis,
     [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
 {
     return innerStream.Length;
 }
예제 #18
0
 public static void Write(IO::FileStream aThis, byte[] aBuffer, int aOffset, int aCount,
     [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
 {
     innerStream.Write(aBuffer, aOffset, aCount);
 }
예제 #19
0
 public static int Read(IO::FileStream aThis, byte[] aBuffer, int aOffset, int aCount,
     [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
 {
     return innerStream.Read(aBuffer, aOffset, aCount);
 }
예제 #20
0
        // This plug basically forwards all calls to the $$InnerStream$$ stream, which is supplied by the file system.

        //  public static unsafe void Ctor(String aThis, [FieldAccess(Name = "$$Storage$$")]ref Char[] aStorage, Char[] aChars, int aStartIndex, int aLength,

        public static void Ctor(IO::FileStream aThis, string aPathname, IO::FileMode aMode,
            [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
        {
            innerStream = VFSManager.GetFileStream(aPathname);
        }
예제 #21
0
        /// <summary>
        /// <para>Begins an asynchronous send to the upload route.</para>
        /// </summary>
        /// <param name="path">Path in the user's Dropbox to save the file.</param>
        /// <param name="mode">Selects what to do if the file already exists.</param>
        /// <param name="autorename">If there's a conflict, as determined by <paramref
        /// name="mode" />, have the Dropbox server try to autorename the file to avoid
        /// conflict.</param>
        /// <param name="clientModified">The value to store as the <paramref
        /// name="clientModified" /> timestamp. Dropbox automatically records the time at which
        /// the file was written to the Dropbox servers. It can also record an additional
        /// timestamp, provided by Dropbox desktop clients, mobile clients, and API apps of
        /// when the file was actually created or modified.</param>
        /// <param name="mute">Normally, users are made aware of any file modifications in
        /// their Dropbox account via notifications in the client software. If <c>true</c>,
        /// this tells the clients that this modification shouldn't result in a user
        /// notification.</param>
        /// <param name="body">The document to upload</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="callbackState">A user provided object that distinguished this send
        /// from other send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginUpload(string path,
                                            WriteMode mode = null,
                                            bool autorename = false,
                                            sys.DateTime? clientModified = null,
                                            bool mute = false,
                                            io.Stream body = null,
                                            sys.AsyncCallback callback = null,
                                            object callbackState = null)
        {
            var commitInfo = new CommitInfo(path,
                                            mode,
                                            autorename,
                                            clientModified,
                                            mute);

            return this.BeginUpload(commitInfo, body, callback, callbackState);
        }
예제 #22
0
        /// <summary>
        /// <para>Create a new file with the contents provided in the request.</para>
        /// </summary>
        /// <param name="path">Path in the user's Dropbox to save the file.</param>
        /// <param name="mode">Selects what to do if the file already exists.</param>
        /// <param name="autorename">If there's a conflict, as determined by <paramref
        /// name="mode" />, have the Dropbox server try to autorename the file to avoid
        /// conflict.</param>
        /// <param name="clientModified">The value to store as the <paramref
        /// name="clientModified" /> timestamp. Dropbox automatically records the time at which
        /// the file was written to the Dropbox servers. It can also record an additional
        /// timestamp, provided by Dropbox desktop clients, mobile clients, and API apps of
        /// when the file was actually created or modified.</param>
        /// <param name="mute">Normally, users are made aware of any file modifications in
        /// their Dropbox account via notifications in the client software. If <c>true</c>,
        /// this tells the clients that this modification shouldn't result in a user
        /// notification.</param>
        /// <param name="body">The document to upload</param>
        /// <returns>The task that represents the asynchronous send operation. The TResult
        /// parameter contains the response from the server.</returns>
        /// <exception cref="Dropbox.Api.ApiException{UploadError}">Thrown if there is an error
        /// processing the request; This will contain a <see cref="UploadError"/>.</exception>
        public t.Task<FileMetadata> UploadAsync(string path,
                                                WriteMode mode = null,
                                                bool autorename = false,
                                                sys.DateTime? clientModified = null,
                                                bool mute = false,
                                                io.Stream body = null)
        {
            var commitInfo = new CommitInfo(path,
                                            mode,
                                            autorename,
                                            clientModified,
                                            mute);

            return this.UploadAsync(commitInfo, body);
        }
예제 #23
0
        /// <summary>
        /// <para>Begins an asynchronous send to the upload route.</para>
        /// </summary>
        /// <param name="commitInfo">The request parameters.</param>
        /// <param name="body">The content to upload.</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="state">A user provided object that distinguished this send from other
        /// send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginUpload(CommitInfo commitInfo, io.Stream body, sys.AsyncCallback callback, object state = null)
        {
            var task = this.UploadAsync(commitInfo, body);

            return enc.Util.ToApm(task, callback, state);
        }
예제 #24
0
 /// <summary>
 /// <para>Create a new file with the contents provided in the request.</para>
 /// </summary>
 /// <param name="commitInfo">The request parameters</param>
 /// <param name="body">The content to upload.</param>
 /// <returns>The task that represents the asynchronous send operation. The TResult
 /// parameter contains the response from the server.</returns>
 /// <exception cref="Dropbox.Api.ApiException{UploadError}">Thrown if there is an error
 /// processing the request; This will contain a <see cref="UploadError"/>.</exception>
 public t.Task<FileMetadata> UploadAsync(CommitInfo commitInfo, io.Stream body)
 {
     return this.Transport.SendUploadRequestAsync<CommitInfo, FileMetadata, UploadError>(commitInfo, body, "content", "/files/upload", CommitInfo.Encoder, FileMetadata.Decoder, UploadError.Decoder);
 }
예제 #25
0
 public static long get_Position(IO::FileStream aThis,
                                 [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
 {
     return innerStream.Position;
 }
예제 #26
0
 public static long Seek(IO::FileStream aThis,
                         [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream, long offset, SeekOrigin origin)
 {
     return innerStream.Seek(offset, origin);
 }
예제 #27
0
 public static void Flush(IO::FileStream aThis,
    [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
 {
     innerStream.Flush();
 }
예제 #28
0
        /// <summary>
        /// <para>Finish an upload session and save the uploaded data to the given file
        /// path.</para>
        /// </summary>
        /// <param name="cursor">Contains the upload session ID and the offset.</param>
        /// <param name="commit">Contains the path and other optional modifiers for the
        /// commit.</param>
        /// <param name="body">The document to upload</param>
        /// <returns>The task that represents the asynchronous send operation. The TResult
        /// parameter contains the response from the server.</returns>
        /// <exception cref="Dropbox.Api.ApiException{UploadSessionFinishError}">Thrown if
        /// there is an error processing the request; This will contain a <see
        /// cref="UploadSessionFinishError"/>.</exception>
        public t.Task<FileMetadata> UploadSessionFinishAsync(UploadSessionCursor cursor,
                                                             CommitInfo commit,
                                                             io.Stream body)
        {
            var uploadSessionFinishArg = new UploadSessionFinishArg(cursor,
                                                                    commit);

            return this.UploadSessionFinishAsync(uploadSessionFinishArg, body);
        }
예제 #29
0
 public static void set_Position(IO::FileStream aThis,
                                 [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream, long value)
 {
     innerStream.Position = value;
 }
예제 #30
0
        /// <summary>
        /// <para>Begins an asynchronous send to the upload session finish route.</para>
        /// </summary>
        /// <param name="cursor">Contains the upload session ID and the offset.</param>
        /// <param name="commit">Contains the path and other optional modifiers for the
        /// commit.</param>
        /// <param name="body">The document to upload</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="callbackState">A user provided object that distinguished this send
        /// from other send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginUploadSessionFinish(UploadSessionCursor cursor,
                                                         CommitInfo commit,
                                                         io.Stream body,
                                                         sys.AsyncCallback callback,
                                                         object callbackState = null)
        {
            var uploadSessionFinishArg = new UploadSessionFinishArg(cursor,
                                                                    commit);

            return this.BeginUploadSessionFinish(uploadSessionFinishArg, body, callback, callbackState);
        }