Exemplo n.º 1
0
Arquivo: File.cs Projeto: nomit007/f4
        public static File createTemp(string prefix, string suffix, File dir)
        {
            if (prefix == null || prefix.Length == 0) prefix = "fan";
              if (suffix == null) suffix = ".tmp";

              string parent = null;
              if (dir == null)
              {
            parent = System.IO.Path.GetTempPath();
              }
              else
              {
            if (!(dir is LocalFile)) throw IOErr.make("Dir is not on local file system: " + dir).val;
            parent = ((LocalFile)dir).m_file.FullName;
              }

              try
              {
            string name = parent + '\\' + prefix + suffix;
            int count = 1;
            while (System.IO.File.Exists(name))
              name = parent + '\\' + prefix + (count++) + suffix;
            LocalFile temp = new LocalFile(new System.IO.FileInfo(name));
            temp.create();
            return temp;
              }
              catch (System.IO.IOException e)
              {
            throw IOErr.make(e).val;
              }
        }
Exemplo n.º 2
0
        public static File createTemp(string prefix, string suffix, File dir)
        {
            if (prefix == null || prefix.Length == 0)
            {
                prefix = "fan";
            }
            if (suffix == null)
            {
                suffix = ".tmp";
            }

            string parent = null;

            if (dir == null)
            {
                parent = System.IO.Path.GetTempPath();
            }
            else
            {
                if (!(dir is LocalFile))
                {
                    throw IOErr.make("Dir is not on local file system: " + dir).val;
                }
                parent = ((LocalFile)dir).m_file.FullName;
            }

            try
            {
                string name  = parent + '\\' + prefix + suffix;
                int    count = 1;
                while (System.IO.File.Exists(name))
                {
                    name = parent + '\\' + prefix + (count++) + suffix;
                }
                LocalFile temp = new LocalFile(new System.IO.FileInfo(name));
                temp.create();
                return(temp);
            }
            catch (System.IO.IOException e)
            {
                throw IOErr.make(e).val;
            }
        }