LocalFile represents a file or directory in the local file system.
Inheritance: File
示例#1
0
文件: Zip.cs 项目: nomit007/f4
        internal ZipOutputStream m_zipOut; // write only

        #endregion Fields

        #region Constructors

        private Zip(File f)
        {
            try
              {
            // only support local files
            if (!(f is LocalFile))
              throw IOErr.make("Only local files supported: " + f).val;

            // open the file
            this.m_file = (LocalFile)f;
            this.m_zipFile = new ZipFile(m_file.m_file.FullName);
              }
              catch (System.Exception e)
              {
            // NOTE: use ctor instead of make() to force type == IOErr
            throw new IOErr(e).val;
              }
        }
示例#2
0
        public override File moveTo(File to)
        {
            if (isDir() != to.isDir())
            {
                if (isDir())
                {
                    throw ArgErr.make("moveTo must be dir `" + to + "`").val;
                }
                else
                {
                    throw ArgErr.make("moveTo must not be dir `" + to + "`").val;
                }
            }

            if (!(to is LocalFile))
            {
                throw IOErr.make("Cannot move LocalFile to " + to.@typeof()).val;
            }
            LocalFile dest = (LocalFile)to;

            if (dest.exists())
            {
                throw IOErr.make("moveTo already exists: " + to).val;
            }

            try
            {
                if (m_file is FileInfo)
                {
                    (m_file as FileInfo).MoveTo((dest.m_file as FileInfo).FullName);
                }
                else
                {
                    (m_file as DirectoryInfo).MoveTo((dest.m_file as DirectoryInfo).FullName);
                }
            }
            catch (System.IO.IOException)
            {
                throw IOErr.make("moveTo failed: " + to).val;
            }

            return(to);
        }
示例#3
0
 public ZipEntryFile(Zip parent, ZipEntry entry)
     : base(Uri.fromStr("/" + LocalFile.fileNameToUriName(entry.Name)))
 {
     this.m_parent = parent;
     this.m_entry  = entry;
 }
示例#4
0
文件: Sys.cs 项目: nomit007/f4
        //////////////////////////////////////////////////////////////////////////
        // Sys Config
        //////////////////////////////////////////////////////////////////////////
        private static Map initSysConfig()
        {
            try
              {
            string path = FileUtil.combine(m_homeDir, "etc", "sys", "config.props");
            LocalFile f = new LocalFile(new FileInfo(path));

            if (f.exists())
            {
              try
              {
            return f.readProps();
              }
              catch (Exception e)
              {
            Console.WriteLine("ERROR: Invalid props file: " + f);
            Console.WriteLine("  " + e);
              }
            }
              }
              catch (Exception e)
              {
            throw initFail("sysConfig", e);
              }
              return m_emptyStrStrMap;
        }