Parse() public method

public Parse ( String item ) : void
item String
return void
コード例 #1
0
ファイル: FtpListing.cs プロジェクト: pavadik/internetpack
        public void Parse(String list, Boolean includeUpDir)
        {
            this.Clear();

            Boolean lFoundUpDir = false;

            //String[] lItems = Regex.Split(list, @"(?:\r\n|\r|\n)");
            String[] lItems = SplitLines(list);

            for (Int32 i = 0; i < lItems.Length; i++)
            {
                String lItem = lItems[i].Trim();

                if (String.IsNullOrEmpty(lItem))
                {
                    continue;
                }

                if (lItem.ToLower().StartsWith("total"))
                {
                    continue;
                }

                try
                {
                    FtpListingItem lNewItem = new FtpListingItem();
                    lNewItem.Parse(lItem);

                    this.Add(lNewItem);

                    if (lNewItem.Directory && lNewItem.FileName == "..")
                    {
                        lFoundUpDir = true;
                    }
                }
                catch (Exception ex)
                {
                    if (!(ex is FormatException))
                    {
                        if (defined("ECHOES") && (!(ex is IndexOutOfRangeException)))
                        {
                            throw ex;
                        }
                        else if (!defined("ECHOES") && (!(ex is RTLException)))
                        {
                            throw ex;
                        }
                    }
                }
            }

            if (includeUpDir && !lFoundUpDir)
            {
                FtpListingItem lUpItem = new FtpListingItem();
                lUpItem.Directory = true;
                lUpItem.FileName  = "..";
                this.Insert(0, lUpItem);
            }
        }
コード例 #2
0
        public void Parse(String list, Boolean includeUpDir)
        {
            this.Clear();

            Boolean lFoundUpDir = false;

            String[] lItems = Regex.Split(list, @"(?:\r\n|\r|\n)");

            for (Int32 i = 0; i < lItems.Length; i++)
            {
                String lItem = lItems[i].Trim();

                if (String.IsNullOrEmpty(lItem))
                {
                    continue;
                }

                if (lItem.StartsWith("total", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                try
                {
                    FtpListingItem lNewItem = new FtpListingItem();
                    lNewItem.Parse(lItem);

                    this.Add(lNewItem);

                    if (lNewItem.Directory && lNewItem.FileName == "..")
                    {
                        lFoundUpDir = true;
                    }
                }
                catch (IndexOutOfRangeException)
                {
                }
                catch (FormatException)
                {
                }
            }

            if (includeUpDir && !lFoundUpDir)
            {
                FtpListingItem lUpItem = new FtpListingItem();
                lUpItem.Directory = true;
                lUpItem.FileName  = "..";
                this.Insert(0, lUpItem);
            }
        }
コード例 #3
0
ファイル: FtpListing.cs プロジェクト: remobjects/internetpack
		public void Parse(String list, Boolean includeUpDir)
		{
			this.Clear();

			Boolean lFoundUpDir = false;

			String[] lItems = Regex.Split(list, @"(?:\r\n|\r|\n)");

			for (Int32 i = 0; i < lItems.Length; i++)
			{
				String lItem = lItems[i].Trim();

				if (String.IsNullOrEmpty(lItem))
					continue;

				if (lItem.StartsWith("total", StringComparison.OrdinalIgnoreCase))
					continue;

				try
				{
					FtpListingItem lNewItem = new FtpListingItem();
					lNewItem.Parse(lItem);

					this.Add(lNewItem);

					if (lNewItem.Directory && lNewItem.FileName == "..")
						lFoundUpDir = true;
				}
				catch (IndexOutOfRangeException)
				{
				}
				catch (FormatException)
				{
				}
			}

			if (includeUpDir && !lFoundUpDir)
			{
				FtpListingItem lUpItem = new FtpListingItem();
				lUpItem.Directory = true;
				lUpItem.FileName = "..";
				this.Insert(0, lUpItem);
			}
		}