コード例 #1
0
        static bool IsCacheFull(EFileType fileType, byte[] incomingFile)
        {
            double size       = GetDirectorySizeInMb(PiUtilities.SavePath + fileType) + (incomingFile.Length / (double)(1024 * 1024));
            long   cacheLimit = 0;

            switch (fileType)
            {
            case EFileType.Audio:
            {
                cacheLimit = AudioCacheLimit;
                break;
            }

            case EFileType.Video:
            {
                cacheLimit = VideoCacheLimit;
                break;
            }

            case EFileType.Image:
            {
                cacheLimit = ImageCacheLimit;
                break;
            }

            case EFileType.Data:
            {
                cacheLimit = DataCacheLimit;
                break;
            }
            }

            return(size >= cacheLimit);
        }
コード例 #2
0
 public FileInformationRequest(EFileType type, string filename)
     : base("FileInformationRequest: " + filename)
 {
     Type     = type;
     Filename = filename;
     ID       = -1;
 }
コード例 #3
0
ファイル: CFileManager.cs プロジェクト: jasonyyl/Tools
        public static EFileFlag CreateFile(string dir, string name, EFileType ft)
        {
            if (Directory.Exists(dir))
            {
                string ext  = string.Empty;
                string path = Path.Combine(dir, name);
                switch (ft)
                {
                case EFileType.Text: ext = ".txt"; break;

                case EFileType.Excel: ext = ".xlsm"; break;

                default:
                    break;
                }
                path += ext;
                if (File.Exists(path))
                {
                    return(EFileFlag.File_Exist);
                }
                else
                {
                    File.Create(path);
                }
                return(EFileFlag.Success);;
            }
            else
            {
                return(EFileFlag.Directory_NotExist);
            }
        }
コード例 #4
0
        public static EFileType StringEFileType(string val)
        {
            EFileType _rVal = EFileType.NULL;

            if (string.IsNullOrEmpty(val))
            {
                return(EFileType.NULL);
            }
            val = val.ToUpper().Trim();
            switch (val)
            {
            case "":
            case "NULL":
                _rVal = EFileType.NULL;
                break;

            case "DOCUMENT_IMPORT":
                _rVal = EFileType.DOCUMENT_IMPORT;
                break;

            case "FILE":
                _rVal = EFileType.FILE;
                break;

            case "IMAGE":
                _rVal = EFileType.IMAGE;
                break;

            default:
                break;
            }

            return(_rVal);
        }
コード例 #5
0
        internal static string GetFilePath(EFileType fileType)
        {
            if (!Enum.IsDefined(typeof(EFileType), fileType))
            {
                ArchiLogger.LogNullError(nameof(fileType));

                return(null);
            }

            switch (fileType)
            {
            case EFileType.Config:

                return(Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalConfigFileName));

            case EFileType.Database:

                return(Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalDatabaseFileName));

            default:
                ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(fileType), fileType));

                return(null);
            }
        }
コード例 #6
0
        private void JudgeView(EFileType filetype)
        {
            this.CurrentType = filetype;
            switch (filetype)
            {
            case EFileType.Scene:
                this.entryWidth.MaxValue  = 2147483647;
                this.entryHeight.MaxValue = 2147483647;
                this.SetSensitive(this.DefaultSize.Width, this.DefaultSize.Height, false);
                break;

            case EFileType.Layer:
                this.entryWidth.MaxValue  = 4096;
                this.entryHeight.MaxValue = 4096;
                this.SetSensitive(this.DefaultSize.Width, this.DefaultSize.Height, true);
                break;

            case EFileType.Node:
                this.SetSensitive(0, 0, false);
                break;

            case EFileType.Plist:
                this.SetSensitive(-1, -1, false);
                break;
            }
        }
コード例 #7
0
ファイル: FormMain.cs プロジェクト: HeinerMuc/archive
        /// <summary>
        /// Fügt eine entsprechende Datendatei in den entsprechenden Order:
        /// c-data
        /// r-data
        /// m-data
        /// </summary>
        /// <param name="client"></param>
        /// <param name="?"></param>
        public void AddFileToUpdateFolder(FTPSClient client, string folder, string relFilename, EFileType fileType)
        {
            //In Update Verzeichniss legen
            IList<DirectoryListItem> hashDirs=client.GetDirectoryList(folder+"/");

            //Updatedatei anlegen
            string uniqueID=Various.GetUniqueID();
            string uniqueIDSHA1=Hash.SHA1.HashString(uniqueID);

            string filenameLocal=FileSystem.TempPath+uniqueIDSHA1;

            List<string> lines=new List<string>();
            lines.Add(relFilename);
            lines.Add(fileType.ToString());
            File.WriteAllLines(filenameLocal, lines.ToArray());

            //Updatedatei hochladen
            foreach(DirectoryListItem dli in hashDirs)
            {
                if(Globals.ClientID==dli.Name) continue;
                client.PutFile(filenameLocal, folder+"/"+dli.Name+"/"+uniqueIDSHA1);
            }

            //Log
            Globals.Log.Add(LogLevel.Information, "Updatedatei {0} wurde hochgeladen ({1}).", relFilename, folder);
        }
コード例 #8
0
ファイル: FileNode.cs プロジェクト: alexfordc/Au
    //currently not used
    //this ctor is used when creating new item of known type
    //public FileNode(FilesModel model, string name, EFileType type, string linkTarget = null)
    //{
    //	_model = model;
    //	_type = type;
    //	_name = name;
    //	_id = _model.AddGetId(this);
    //	_CtorMisc(linkTarget);
    //}

    //this ctor is used when creating new item, importing items from files etc.
    //name is filename with extension.
    //sourcePath is used when need to get file text to detect type.
    //template used when creating new item, to detect item type.
    public FileNode(FilesModel model, string name, string sourcePath, bool isFolder, string linkTarget = null, string template = null)
    {
        //detect file type
        EFileType type;

        if (isFolder)
        {
            type = EFileType.Folder;
        }
        else if (template == "Script.cs")
        {
            type = EFileType.Script;
        }
        else if (template == "Class.cs" || template == "Partial.cs")
        {
            type = EFileType.Class;
        }
        else
        {
            type = DetectFileType(sourcePath);
        }

        _model = model;
        _type  = type;
        _name  = name;
        _id    = _model.AddGetId(this);
        _CtorMisc(linkTarget);
    }
コード例 #9
0
ファイル: FileImpl.cs プロジェクト: RudnetsDmitry/MVC
 public FileImpl(int file_id, string name, EFileType file_type, IFile parent)
 {
     this.name = name;
     this.file_type = file_type;
     this.parent = parent;
     this.file_id = file_id;
 }
コード例 #10
0
 //this ctor is used when creating new item of known type
 public FileNode(FilesModel model, string name, EFileType type)
 {
     _model = model;
     _type  = type;
     _SetName(name);
     _id = _model.AddGetId(this);
 }
コード例 #11
0
        static void MakeSpaceForFile(EFileType fileType, byte[] fileBytes)
        {
            if (Directory.Exists(PiUtilities.SavePath + fileType) && IsCacheFull(fileType, fileBytes))
            {
                Action <IEnumerable <FileInfo> > remover = (input) =>
                {
                    foreach (var file in input)
                    {
                        File.Delete(file.FullName);
                    }
                };

                var dir = new DirectoryInfo(PiUtilities.SavePath + fileType.ToString());

                List <FileInfo> files = dir.GetFiles("*.*", SearchOption.TopDirectoryOnly).ToList();
                files.Sort((a, b) => a.LastAccessTimeUtc.CompareTo(b.LastAccessTimeUtc));
                int i = 0;
                while (IsCacheFull(fileType, fileBytes))
                {
                    if (i >= files.Count)
                    {
                        return;
                    }
                    remover.Invoke(files.Skip(i).Take(1));
                    i++;
                }
            }
        }
コード例 #12
0
ファイル: AFTextureAtlas.cs プロジェクト: mhznet/bate-rebate
        public AFTextureAtlas(string name, Texture2D texture, string path, EFileType fileType)
        {
            m_name         = name;
            m_texturesInfo = new Dictionary <string, AFTextureInfo>();
            m_texture      = texture;

            ParseFile(path, fileType);
        }
コード例 #13
0
 public ActionResult Index2(EFileType type,
                            string library,
                            string version,
                            string file      = null,
                            ECacheType renew = ECacheType.cache)
 {
     return(View("Index"));
 }
コード例 #14
0
 public FileTypeInfo(Image img, string name, EFileType filetype, string extension, string displayName)
 {
     this.Icon        = img;
     this.Name        = name;
     this.FileType    = filetype;
     this.Extension   = extension;
     this.DisplayName = displayName;
 }
コード例 #15
0
        public AssetSearcher(EFileType type, RoutedEventHandler handler)
        {
            InitializeComponent();

            this.type = type;
            files     = Manager.Instance.SearchForFileType(type);
            AddFiles(handler);
        }
コード例 #16
0
ファイル: FileNode.cs プロジェクト: alexfordc/Au
    //this ctor is used when reading files.xml
    FileNode(XmlReader x, FileNode parent, FilesModel model)
    {
        _model = model;
        if (parent == null)          //the root node
        {
            if (x.Name != "files")
            {
                throw new ArgumentException("XML root element name must be 'files'");
            }
            x["max-i"].ToInt(out uint u);
            _model.MaxId = u;
        }
        else
        {
            _type = x.Name switch
            {
                "d" => EFileType.Folder,
                "s" => EFileType.Script,
                "c" => EFileType.Class,
                "n" => EFileType.NotCodeFile,
                _ => throw new ArgumentException("XML element name must be 'd', 's', 'c' or 'n'"),
            };
            uint id = 0, testScriptId = 0; string linkTarget = null, icon = null;
            while (x.MoveToNextAttribute())
            {
                var v = x.Value;
                switch (x.Name)
                {
                case "n": _name = v; break;

                case "i": v.ToInt(out id); break;

                case "f": _flags = (_Flags)v.ToInt(); break;

                case "path": linkTarget = v; break;

                case "icon": icon = v; break;

                case "run": v.ToInt(out testScriptId); break;
                }
            }
            if (_name.NE())
            {
                throw new ArgumentException("no 'n' attribute in XML");
            }
            _id = _model.AddGetId(this, id);
            _CtorMisc(linkTarget);
            if (icon != null && linkTarget == null)
            {
                _iconOrLinkTarget = icon;
            }
            if (testScriptId != 0)
            {
                _testScriptId = testScriptId;
            }
        }
    }
コード例 #17
0
            public EditFileInfo(EFileType fileType, string fileRelative_Path, string fieldName, string value, string strComment)
            {
                this.FileType          = fileType;
                this.File_RelativePath = fileRelative_Path;
                this.FieldName         = fieldName;
                this.Value             = value;

                this.strJustComment = strComment;
            }
コード例 #18
0
 public Dump(string name, EDumpMode dm, EDumpType dt, EFileType ft, List <double> f = null, double optResolution = Double.NaN)
     : base(name)
 {
     m_dumpMode      = dm;
     m_dumpType      = dt;
     m_fileType      = ft;
     m_frequencies   = (f == null) ? new List <double>() : f;
     m_optResolution = optResolution;
 }
コード例 #19
0
ファイル: FileNode.cs プロジェクト: alexfordc/Au
 //this ctor is used when copying or importing a workspace.
 //Deep-copies fields from f, except _model, _name, _id (generates new) and _testScriptId.
 FileNode(FilesModel model, FileNode f, string name)
 {
     _model            = model;
     _name             = name;
     _type             = f._type;
     _state            = f._state;
     _flags            = f._flags;
     _iconOrLinkTarget = f._iconOrLinkTarget;
     _id = _model.AddGetId(this);
 }
コード例 #20
0
 //this ctor is used when copying or importing a workspace.
 //Deep-copies fields from f, except _model, _name, _id (generates new) and _testScriptId.
 FileNode(FilesModel model, FileNode f, string name)
 {
     _model = model;
     _SetName(name);
     _type       = f._type;
     _state      = f._state;
     _flags      = f._flags;
     _linkTarget = f._linkTarget;
     _icon       = f.CustomIconName;
     _id         = _model.AddGetId(this);
 }
コード例 #21
0
 //this ctor is used when importing items from files etc.
 //name is filename with extension.
 //sourcePath is used to get file text to detect type when !isFolder.
 public FileNode(FilesModel model, string name, string sourcePath, bool isFolder, string linkTarget = null)
 {
     _model = model;
     _type  = isFolder ? EFileType.Folder : _DetectFileType(sourcePath);
     _SetName(name);
     _id = _model.AddGetId(this);
     if (!linkTarget.NE() && !isFolder)
     {
         _linkTarget = linkTarget;
     }
 }
コード例 #22
0
ファイル: CTextAssetMgr.cs プロジェクト: ditto21c/ProjectDnS
    public BinaryReader LoadTextAsset(EFileType Type, string FileName)
    {
        TextAsset Asset = GetAsset(Type, FileName);

        if (Asset == null)
        {
            return(null);
        }
        Stream stream = new MemoryStream(Asset.bytes);

        return(new BinaryReader(stream));
    }
コード例 #23
0
ファイル: AFTextureAtlas.cs プロジェクト: mhznet/bate-rebate
        public AFTextureAtlas(string name, string path, EFileType fileType)
        {
            m_texture = Resources.Load <Texture2D>(path);

            if (m_texture == null)
            {
                throw new FileLoadException("Texture not found");
            }

            m_name         = name;
            m_texturesInfo = new Dictionary <string, AFTextureInfo>();
            ParseFile(path, fileType);
        }
コード例 #24
0
 /// <summary>
 /// Construtor que recebe os atributos do Objeto Project a ser criados
 /// </summary>
 /// <param name="name">Nome do Projeto</param>
 /// <param name="licenseId">License ID da licença que pertence ao Projeto</param>
 /// <param name="permissionId">Permission ID da base que pertence ao Projeto</param>
 /// <param name="description">Descrição do projeto</param>
 /// <param name="fileType">Tipo de Arquivo que será usado na integração</param>
 /// <param name="divisorChar">Caracter divisor do arquivo</param>
 /// <param name="fileName">Nome do arquivo que será importado</param>
 /// <param name="errorEmail">E-mail em caso de erros na integração do projeto</param>
 /// <param name="sendType">Tipo de Envio</param>
 /// <param name="ignoreFirstLine">Boolean para Ignorar ou não o cabeçalho</param>
 public CreateProjectCommand(string name, Guid licenseId, Guid permissionId, string description, EFileType fileType, char divisorChar, string fileName, string errorEmail, ESendType sendType, bool ignoreFirstLine)
 {
     Name            = name;
     LicenseId       = licenseId;
     PermissionId    = permissionId;
     Description     = description;
     FileType        = fileType;
     DivisorChar     = divisorChar;
     FileName        = fileName;
     ErrorEmail      = errorEmail;
     SendType        = sendType;
     IgnoreFirstLine = ignoreFirstLine;
     ProjectStatus   = EProjectStatus.Active;
 }
コード例 #25
0
ファイル: AFTextureAtlas.cs プロジェクト: mhznet/bate-rebate
 private void ParseFile(string path, EFileType fileType)
 {
     if (fileType == EFileType.kTextTypes_Json)
     {
         ParseJsonFile(path);
     }
     else if (fileType == EFileType.kTextTypes_Csv)
     {
         ParseCVSFile(path);
     }
     else
     {
         throw new Exception("The parse was not implemented yet");
     }
 }
コード例 #26
0
 public FileReference(
     Bam.Core.TokenizedString path,
     EFileType type,
     Project project,
     bool explicitType      = false,
     ESourceTree sourceTree = ESourceTree.NA)
     :
     this()
 {
     this.Path         = path;
     this.Type         = type;
     this.Project      = project;
     this.SourceTree   = sourceTree;
     this.ExplicitType = explicitType;
 }
コード例 #27
0
    //this ctor is used when reading files.xml
    FileNode(XmlReader x, FileNode parent, FilesModel model)
    {
        _model = model;
        if (parent == null)           //the root node
        {
            if (x.Name != "files")
            {
                throw new ArgumentException("XML root element name must be 'files'");
            }
            x["max-i"].ToInt(out uint u);
            _model.MaxId = u;
        }
        else
        {
            _type = XmlTagToFileType(x.Name, canThrow: true);
            uint id = 0;
            while (x.MoveToNextAttribute())
            {
                var v = x.Value; if (v.NE())
                {
                    continue;
                }
                switch (x.Name)
                {
                case "n": _SetName(v); break;

                case "i": v.ToInt(out id); break;

                case "f": _flags = (_Flags)v.ToInt(); break;

                case "path": if (!IsFolder)
                    {
                        _linkTarget = v;
                    }
                    break;

                case "icon": _icon = v; break;

                case "run": v.ToInt(out _testScriptId); break;
                }
            }
            if (_name == null)
            {
                throw new ArgumentException("no 'n' attribute in XML");
            }
            _id = _model.AddGetId(this, id);
        }
    }
コード例 #28
0
 public FileReference(
     Bam.Core.TokenizedString path,
     EFileType type,
     Project project,
     bool explicitType      = false,
     ESourceTree sourceTree = ESourceTree.NA,
     string relativePath    = null)
     :
     base(project, path.Parse(), "PBXFileReference", type.ToString(), project.GUID, explicitType.ToString(), sourceTree.ToString(), relativePath)
 {
     this.Path         = path;
     this.Type         = type;
     this.SourceTree   = sourceTree;
     this.ExplicitType = explicitType;
     this.RelativePath = relativePath;
 }
コード例 #29
0
        public virtual IFileProvider GetFileProvider(EFileType fileType)
        {
            IFileProvider _fileProvider = null;

            switch (fileType)
            {
            case EFileType.Product:
                _fileProvider = new ProductFileProvider();
                break;

            case EFileType.Meal:
                _fileProvider = new MealFileProvider();
                break;
            }
            return(_fileProvider);
        }
コード例 #30
0
            public List <VirtualFile> SearchForFileType(EFileType type)
            {
                List <VirtualFile> files = new List <VirtualFile>();
                Regex reg = null;

                if (type == EFileType.FONT)
                {
                    reg = new Regex(@"\.ttf|\.otf|\.woff");
                }
                else if (type == EFileType.SPRITE)
                {
                    reg = new Regex(@"\.jpeg|\.png|\.bmp|\.jpg");
                }
                else if (type == EFileType.SOUND)
                {
                    reg = new Regex(@"\.mp3|\.wav|\.flac");
                }

                if (reg == null)
                {
                    return(files);
                }

                foreach (var file in Root.files)
                {
                    if (reg.IsMatch(file.RealFilePath))
                    {
                        files.Add(file);
                    }
                }
                foreach (var dir in Root.directories)
                {
                    foreach (var file in dir.files)
                    {
                        if (reg.IsMatch(file.RealFilePath))
                        {
                            files.Add(file);
                        }
                    }
                }

                return(files);
            }
コード例 #31
0
 public InstalledExtraFile(string filepath, EFileType type, Mod.MEGame game, Action <InstalledExtraFile> notifyDeleted = null)
 {
     this.game          = game;
     this.notifyDeleted = notifyDeleted;
     FilePath           = filepath;
     FileName           = Path.GetFileName(filepath);
     FileType           = type;
     DisplayName        = FileName;
     switch (type)
     {
     case EFileType.DLL:
         var info = FileVersionInfo.GetVersionInfo(FilePath);
         if (!string.IsNullOrWhiteSpace(info.ProductName))
         {
             DisplayName += $@" ({info.ProductName.Trim()})";
         }
         break;
     }
     DeleteCommand = new GenericCommand(DeleteExtraFile, CanDeleteFile);
 }
コード例 #32
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fileDataFields"></param>
 public FileDataFields(FileDataFields fileDataFields)
 {
     sUnitName        = fileDataFields.sUnitName;
     sUnitVersion     = fileDataFields.sUnitVersion;
     sDate            = fileDataFields.sDate;
     sFilename        = fileDataFields.sFilename;
     sGPS             = fileDataFields.sGPS;
     sTransmitTime    = fileDataFields.sTransmitTime;
     sSize            = fileDataFields.sSize;
     sGainUsed        = fileDataFields.sGainUsed;
     nSyncDuration    = fileDataFields.nSyncDuration;
     sHardwareVersion = fileDataFields.sHardwareVersion;
     sSimCcid         = fileDataFields.sSimCcid;
     iIndex           = fileDataFields.iIndex;
     fIsLogFile       = fileDataFields.fIsLogFile;
     fLogAlreadyRead  = fileDataFields.fLogAlreadyRead;
     eLogType         = fileDataFields.eLogType;
     eFileType        = fileDataFields.eFileType;
     fBatteryVoltageBeforeRecording = fileDataFields.fBatteryVoltageBeforeRecording;
     fBatteryVoltageAfterRecording  = fileDataFields.fBatteryVoltageAfterRecording;
 }
コード例 #33
0
 public Dump(string name, EDumpMode dm, EDumpType dt, EFileType ft, double f, double optResolution = Double.NaN)
     : this(name, dm, dt, ft, new List<double> { f }, optResolution)
 {
 }
コード例 #34
0
ファイル: FileReference.cs プロジェクト: knocte/BuildAMation
 public FileReference(
     Bam.Core.TokenizedString path,
     EFileType type,
     Project project,
     bool explicitType = false,
     ESourceTree sourceTree = ESourceTree.NA)
     : this()
 {
     this.Path = path;
     this.Type = type;
     this.Project = project;
     this.SourceTree = sourceTree;
     this.ExplicitType = explicitType;
 }
コード例 #35
0
ファイル: FileReturn.cs プロジェクト: HeinerMuc/archive
 public FileReturn(EFileType fileType, string fileName)
 {
     FileType=fileType;
     Filename=fileName;
 }
コード例 #36
0
 public Dump(string name, EDumpMode dm, EDumpType dt, EFileType ft, List<double> f = null, double optResolution = Double.NaN)
     : base(name)
 {
     m_dumpMode = dm;
     m_dumpType = dt;
     m_fileType = ft;
     m_frequencies = (f == null) ? new List<double>() : f;
     m_optResolution = optResolution;
 }