Ejemplo n.º 1
0
        public static List <LogInfo> FileSize(EngineState s, CodeCommand cmd)
        {
            List <LogInfo> logs = new List <LogInfo>();

            Debug.Assert(cmd.Info.GetType() == typeof(CodeInfo_FileSize));
            CodeInfo_FileSize info = cmd.Info as CodeInfo_FileSize;

            string filePath = StringEscaper.Preprocess(s, info.FilePath);

            if (File.Exists(filePath) == false)
            {
                logs.Add(new LogInfo(LogState.Error, $"File [{filePath}] does not exist"));
                return(logs);
            }

            FileInfo fileInfo = new FileInfo(filePath);

            logs.Add(new LogInfo(LogState.Success, $"File [{filePath}] is [{fileInfo.Length}B]", cmd));

            List <LogInfo> varLogs = Variables.SetVariable(s, info.DestVar, fileInfo.Length.ToString());

            logs.AddRange(varLogs);

            return(logs);
        }
Ejemplo n.º 2
0
        public static List <LogInfo> FileSize(EngineState s, CodeCommand cmd)
        {
            List <LogInfo> logs = new List <LogInfo>();

            CodeInfo_FileSize info = cmd.Info.Cast <CodeInfo_FileSize>();

            string filePath = StringEscaper.Preprocess(s, info.FilePath);

            if (!File.Exists(filePath))
            {
                return(LogInfo.LogErrorMessage(logs, $"File [{filePath}] does not exist"));
            }

            FileInfo fileInfo = new FileInfo(filePath);

            logs.Add(new LogInfo(LogState.Success, $"File [{filePath}] is [{fileInfo.Length}B]", cmd));

            List <LogInfo> varLogs = Variables.SetVariable(s, info.DestVar, fileInfo.Length.ToString());

            logs.AddRange(varLogs);

            return(logs);
        }