Beispiel #1
0
        private EnvDTE.ProjectItem GetProjectItem(params object[] modelLocatorInfo)
        {
            if (modelLocatorInfo == null || modelLocatorInfo.Length == 0)
            {
                return(null);
            }

            // Only interested in project items
            foreach (object item in modelLocatorInfo)
            {
                // Simple case where the argument is directly a ProjectItem
                EnvDTE.ProjectItem projectItem = item as EnvDTE.ProjectItem;

                // Case where this is a pathname (whether in the solution of not)
                if (projectItem == null && item is string)
                {
                    EnvDTE.DTE dte = null;
                    if (this.ModelBus != null)
                    {
                        dte = this.ModelBus.GetService(typeof(DTE)) as DTE;
                    }

                    if (dte == null)
                    {
                        dte = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(DTE)) as DTE;
                    }

                    if (dte == null)
                    {
                        return(null);
                    }

                    projectItem = dte.Solution.FindProjectItem((string)item);
                    if (projectItem == null)
                    {
                        //Item is not in the solution. Add existing item to this current project.
                        projectItem = dte.ItemOperations.AddExistingItem((string)item);
                    }
                }

                // We only support project items concening models of the right file extension
                if (projectItem != null && !string.IsNullOrEmpty(projectItem.Name))
                {
                    global::System.IO.FileInfo fi = new global::System.IO.FileInfo(projectItem.Name);
                    if (string.CompareOrdinal(this.FileExtension, fi.Extension) == 0)
                    {
                        return(projectItem);
                    }
                }
            }

            return(null);
        }
            public FormFileInfo(string path)
            {
#if UNITY_STANDALONE
                Size            = new Drawing.Size(320, 120);
                Location        = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - Width / 2, Screen.PrimaryScreen.WorkingArea.Height / 2 - Height / 2);
                FormBorderStyle = FormBorderStyle.FixedSingle;
                Text            = "Properties: ";

                if (global::System.IO.File.Exists(path) == false)
                {
                    return;
                }

                var    info   = new global::System.IO.FileInfo(path);
                var    bytes  = info.Length;
                string sbytes = bytes.ToString() + " bytes";
                if (bytes >= 1000000000)
                {
                    sbytes = (bytes / 1000000000) + " gb";
                }
                if (bytes >= 1000000)
                {
                    sbytes = (bytes / 1000000) + " mb";
                }
                else if (bytes >= 1000)
                {
                    sbytes = (bytes / 1000) + " kb";
                }

                Label labelSize = new Label();
                labelSize.Location = new Point(16, 32);
                labelSize.Text     = "Size: " + sbytes;
                Controls.Add(labelSize);

                Label labelCreationDate = new Label();
                labelCreationDate.Location = new Point(16, 64);
                labelCreationDate.Text     = "Date creation: " + info.CreationTime.ToString("dd.MM.yyyy");
                Controls.Add(labelCreationDate);

                Label labelModDate = new Label();
                labelModDate.Location = new Point(16, 86);
                labelModDate.Text     = "Date modified: " + info.LastWriteTime.ToString();
                Controls.Add(labelModDate);

                string fileName = global::System.IO.Path.GetFileName(path);
                Text += fileName;
#endif
            }
        public static void ReadAllText(this global::System.IO.FileInfo f, Action <string> yield)
        {
            var ff = (__FileInfo)(object)f;

            var r = new FileReader();

            r.onload = IFunction.OfDelegate(
                new Action(
                    delegate
            {
                yield((string)r.result);
            }
                    )
                );

            r.readAsText(ff.InternalFile, null);
        }
Beispiel #4
0
        /// <summary>
        ///     Extracts all the files in the specified zip archive to a directory on the file system and uses the specified
        ///     character encoding for entry names.
        /// </summary>
        /// <param name="this">The path to the archive that is to be extracted.</param>
        /// <param name="destinationDirectoryName">
        ///     The path to the directory in which to place the extracted files, specified as a
        ///     relative or absolute path. A relative path is interpreted as relative to the current working directory.
        /// </param>
        /// <param name="entryNameEncoding">
        ///     The encoding to use when reading or writing entry names in this archive. Specify a
        ///     value for this parameter only when an encoding is required for interoperability with zip archive tools and
        ///     libraries that do not support UTF-8 encoding for entry names.
        /// </param>
        public static void ExtractZipFileToDirectory(this global::System.IO.FileInfo @this,
                                                     string destinationDirectoryName, Encoding entryNameEncoding)
        {
            if (entryNameEncoding == null)
            {
                if (GlobalCompressionOptions.DefaultEncoding != null)
                {
                    entryNameEncoding = GlobalCompressionOptions.DefaultEncoding;
                }
                else
                {
                    throw new ArgumentNullException(nameof(entryNameEncoding));
                }
            }

            ZipFile.ExtractToDirectory(@this.FullName, destinationDirectoryName, entryNameEncoding);
        }
Beispiel #5
0
 public static object stat(string path)
 {
                 #line 42 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
     if (global::System.IO.File.Exists(((string)(path))))
     {
                         #line 43 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
         global::System.IO.FileInfo fi = new global::System.IO.FileInfo(path);
                         #line 47 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
         global::haxe.root.Date tmp  = new global::haxe.root.Date(((global::System.DateTime)((fi as global::System.IO.FileSystemInfo).LastAccessTime)));
         global::haxe.root.Date tmp1 = new global::haxe.root.Date(((global::System.DateTime)((fi as global::System.IO.FileSystemInfo).LastWriteTime)));
                         #line 49 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
         global::haxe.root.Date tmp2 = new global::haxe.root.Date(((global::System.DateTime)((fi as global::System.IO.FileSystemInfo).CreationTime)));
                         #line 44 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
         {
                                 #line 50 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
             int __temp_odecl1 = ((int)(fi.Length));
                                 #line 44 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
             return(new global::haxe.lang.DynamicObject(new int[] { 262801146, 651890926, 1302870512 }, new object[] { tmp1, tmp, tmp2 }, new int[] { 4995541, 5145602, 5246186, 5841808, 499574632, 1214305123, 1269206179, 1280549057 }, new double[] { ((double)(0)), ((double)(0)), ((double)(0)), ((double)(0)), ((double)(0)), ((double)(0)), ((double)(0)), ((double)(__temp_odecl1)) }));
         }
     }
     else if (global::System.IO.Directory.Exists(((string)(path))))
     {
                         #line 58 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
         global::System.IO.DirectoryInfo fi1 = new global::System.IO.DirectoryInfo(path);
                         #line 62 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
         global::haxe.root.Date tmp3 = new global::haxe.root.Date(((global::System.DateTime)((fi1 as global::System.IO.FileSystemInfo).LastAccessTime)));
         global::haxe.root.Date tmp4 = new global::haxe.root.Date(((global::System.DateTime)((fi1 as global::System.IO.FileSystemInfo).LastWriteTime)));
                         #line 59 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
         {
                                 #line 64 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
             global::haxe.root.Date __temp_odecl2 = new global::haxe.root.Date(((global::System.DateTime)((fi1 as global::System.IO.FileSystemInfo).CreationTime)));
                                 #line 59 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
             return(new global::haxe.lang.DynamicObject(new int[] { 262801146, 651890926, 1302870512 }, new object[] { tmp4, tmp3, __temp_odecl2 }, new int[] { 4995541, 5145602, 5246186, 5841808, 499574632, 1214305123, 1269206179, 1280549057 }, new double[] { ((double)(0)), ((double)(0)), ((double)(0)), ((double)(0)), ((double)(0)), ((double)(0)), ((double)(0)), ((double)(0)) }));
         }
     }
     else
     {
                         #line 73 "C:\\HaxeToolkit\\haxe\\std\\cs\\_std\\sys\\FileSystem.hx"
         throw global::haxe.lang.HaxeException.wrap(global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat("Path \'", path), "\' doesn\'t exist"));
     }
 }
        /// <summary>
        /// If a reference can be created from this locator info, then the corresponding
        /// project item will be returned.
        /// </summary>
        private global::EnvDTE.ProjectItem GetProjectItem(params object[] modelLocatorInfo)
        {
            if (modelLocatorInfo == null || modelLocatorInfo.Length == 0)
            {
                return null;
            }

            // Only interested in project items
            foreach (object item in modelLocatorInfo)
            {
                // Simple case where the argument is directly a ProjectItem
                global::EnvDTE.ProjectItem projectItem = item as global::EnvDTE.ProjectItem;

                // Case where this is a pathname (whether in the solution of not)
				if (projectItem == null && item is string)
				{
					global::EnvDTE.DTE dte = this.ModelBus.GetService(typeof(global::EnvDTE.DTE)) as global::EnvDTE.DTE;
					if (dte == null)
						dte = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(global::EnvDTE.DTE)) as global::EnvDTE.DTE;
					if (dte == null)
						return null;
					
					projectItem = dte.Solution.FindProjectItem((string)item);
					if (projectItem == null)
					{
                        //Item is not in the solution. Add existing item to this current project.
						projectItem = dte.ItemOperations.AddExistingItem((string)item);
					}
				}

                // We only support project items concening models of the right file extension
				if (projectItem != null && !string.IsNullOrEmpty(projectItem.Name))
				{
                    global::System.IO.FileInfo fi = new global::System.IO.FileInfo(projectItem.Name);
                    if (string.CompareOrdinal(this.FileExtension, fi.Extension) == 0)
                    {
                        return projectItem;
                    }
                }
            }

            return null;
        }
        protected virtual bool IsValid(string diagramsFileName)
        {
            var l_fileInfo = new global::System.IO.FileInfo(diagramsFileName);

            return(l_fileInfo.Exists && (l_fileInfo.Length > 10));
        }
Beispiel #8
0
 /// <summary>
 ///     Extracts all the files in the specified zip archive to a directory on the file system
 ///     and uses the specified character encoding for entry names.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="destinationDirectory">Pathname of the destination directory.</param>
 /// <param name="entryNameEncoding">
 ///     The encoding to use when reading or writing entry names in
 ///     this archive. Specify a value for this parameter only when an encoding is required for
 ///     interoperability with zip archive tools and libraries that do not support UTF-8 encoding for
 ///     entry names.
 /// </param>
 public static void ExtractZipFileToDirectory(this global::System.IO.FileInfo @this,
                                              DirectoryInfo destinationDirectory, Encoding entryNameEncoding)
 {
     ExtractZipFileToDirectory(@this, destinationDirectory.FullName, entryNameEncoding);
 }
Beispiel #9
0
 /// <summary>Extracts all the files in the specified zip archive to a directory on the file system.</summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="destinationDirectory">Pathname of the destination directory.</param>
 public static void ExtractZipFileToDirectory(this global::System.IO.FileInfo @this,
                                              DirectoryInfo destinationDirectory)
 {
     ExtractZipFileToDirectory(@this, destinationDirectory.FullName, GlobalCompressionOptions.DefaultEncoding);
 }
Beispiel #10
0
 internal static long smethod_13(string string_0)
 {
     global::System.IO.FileInfo fileInfo = new global::System.IO.FileInfo(string_0);
     return(fileInfo.Length);
 }