Пример #1
0
        public static Value lib_fileiocommon_fileWrite(VmContext vm, Value[] args)
        {
            Value[] ints = vm.globals.positiveIntegers;
            if ((args[3].type != 3))
            {
                return(ints[3]);
            }
            int    statusCode    = 0;
            string contentString = null;
            object byteArrayRef  = null;
            int    format        = (int)args[3].internalValue;

            if ((format == 0))
            {
                byteArrayRef = lib_fileiocommon_listToBytes((ListImpl)args[2].internalValue);
                if ((byteArrayRef == null))
                {
                    return(ints[6]);
                }
            }
            else if ((args[2].type != 5))
            {
                return(ints[6]);
            }
            else
            {
                contentString = (string)args[2].internalValue;
            }
            if ((statusCode == 0))
            {
                statusCode = FileIOCommonHelper.FileWrite((string)args[1].internalValue, format, contentString, byteArrayRef);
            }
            return(Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, statusCode));
        }
Пример #2
0
 public static Value lib_fileiocommon_isWindows(VmContext vm, Value[] args)
 {
     if (FileIOCommonHelper.IsWindows())
     {
         return(vm.globals.boolTrue);
     }
     return(vm.globals.boolFalse);
 }
Пример #3
0
        public static Value lib_fileiocommon_directoryCreate(VmContext vm, Value[] args)
        {
            bool          bool1       = false;
            int           i           = 0;
            int           int1        = 0;
            List <string> stringList1 = null;
            Value         hostObject  = args[0];
            string        path        = (string)args[1].internalValue;

            if ((bool)args[2].internalValue)
            {
                int1 = 0;
                if (!FileIOCommonHelper.DirectoryExists(FileIOCommonHelper.GetDirRoot(path)))
                {
                    int1 = 4;
                }
                else
                {
                    stringList1 = new List <string>();
                    bool1       = true;
                    while ((bool1 && !FileIOCommonHelper.DirectoryExists(path)))
                    {
                        stringList1.Add(path);
                        int1 = FileIOCommonHelper.GetDirParent(path, PST_StringBuffer16);
                        path = PST_StringBuffer16[0];
                        if ((int1 != 0))
                        {
                            bool1 = false;
                        }
                    }
                    if (bool1)
                    {
                        i = (stringList1.Count - 1);
                        while ((i >= 0))
                        {
                            path = stringList1[i];
                            int1 = FileIOCommonHelper.CreateDirectory(path);
                            if ((int1 != 0))
                            {
                                i = -1;
                            }
                            i -= 1;
                        }
                    }
                }
            }
            else
            {
                int1 = FileIOCommonHelper.CreateDirectory(path);
            }
            return(Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, int1));
        }
Пример #4
0
        public static int lib_fileiocommon_textToLinesImpl(VmGlobals globals, string text, ListImpl output)
        {
            List <string> stringList = new List <string>();

            FileIOCommonHelper.TextToLines(text, stringList);
            int _len = stringList.Count;
            int i    = 0;

            while ((i < _len))
            {
                Interpreter.Vm.CrayonWrapper.addToList(output, Interpreter.Vm.CrayonWrapper.buildString(globals, stringList[i]));
                i += 1;
            }
            return(0);
        }
Пример #5
0
        public static Value lib_fileiocommon_fileInfo(VmContext vm, Value[] args)
        {
            int mask = (int)args[2].internalValue;

            FileIOCommonHelper.GetFileInfo((string)args[1].internalValue, mask, PST_IntBuffer16, PST_FloatBuffer16);
            ListImpl outputList = (ListImpl)args[3].internalValue;

            Interpreter.Vm.CrayonWrapper.clearList(outputList);
            VmGlobals globals = vm.globals;

            Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildBoolean(globals, (PST_IntBuffer16[0] > 0)));
            Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildBoolean(globals, (PST_IntBuffer16[1] > 0)));
            if (((mask & 1) != 0))
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildInteger(globals, PST_IntBuffer16[2]));
            }
            else
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, globals.valueNull);
            }
            if (((mask & 2) != 0))
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildBoolean(globals, (PST_IntBuffer16[3] > 0)));
            }
            else
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, globals.valueNull);
            }
            if (((mask & 4) != 0))
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildFloat(globals, PST_FloatBuffer16[0]));
            }
            else
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, globals.valueNull);
            }
            if (((mask & 8) != 0))
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildFloat(globals, PST_FloatBuffer16[1]));
            }
            else
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, globals.valueNull);
            }
            return(args[3]);
        }
Пример #6
0
        public static Value lib_fileiocommon_directoryList(VmContext vm, Value[] args)
        {
            Value         diskhost    = args[0];
            string        path        = (string)args[1].internalValue;
            bool          useFullPath = (bool)args[2].internalValue;
            ListImpl      outputList  = (ListImpl)args[3].internalValue;
            List <string> stringList1 = new List <string>();
            int           sc          = FileIOCommonHelper.GetDirectoryList(path, useFullPath, stringList1);

            if ((sc == 0))
            {
                int i = 0;
                while ((i < stringList1.Count))
                {
                    Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildString(vm.globals, stringList1[i]));
                    i += 1;
                }
            }
            return(Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, sc));
        }
Пример #7
0
        public static Value lib_fileiocommon_fileRead(VmContext vm, Value[] args)
        {
            Value        diskHostObject  = args[0];
            string       sandboxedPath   = (string)args[1].internalValue;
            bool         readDataAsBytes = (bool)args[2].internalValue;
            ListImpl     outputList      = (ListImpl)args[3].internalValue;
            List <Value> tList           = new List <Value>();
            int          statusCode      = FileIOCommonHelper.FileRead(sandboxedPath, readDataAsBytes, PST_StringBuffer16, vm.globals.positiveIntegers, tList);

            if (((statusCode == 0) && !readDataAsBytes))
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildString(vm.globals, PST_StringBuffer16[0]));
            }
            else
            {
                Value    t         = Interpreter.Vm.CrayonWrapper.buildList(tList);
                ListImpl tListImpl = (ListImpl)t.internalValue;
                outputList.array    = tListImpl.array;
                outputList.capacity = tListImpl.capacity;
                outputList.size     = tList.Count;
            }
            return(Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, statusCode));
        }
Пример #8
0
        public static Value lib_fileiocommon_directoryDelete(VmContext vm, Value[] args)
        {
            int sc = FileIOCommonHelper.DeleteDirectory((string)args[1].internalValue);

            return(Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, sc));
        }
Пример #9
0
 public static Value lib_fileiocommon_getUserDirectory(VmContext vm, Value[] args)
 {
     return(Interpreter.Vm.CrayonWrapper.buildString(vm.globals, FileIOCommonHelper.GetUserDirectory()));
 }
Пример #10
0
        public static Value lib_fileiocommon_fileMove(VmContext vm, Value[] args)
        {
            int statusCode = FileIOCommonHelper.FileMove((string)args[1].internalValue, (string)args[2].internalValue, (bool)args[3].internalValue, (bool)args[4].internalValue);

            return(Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, statusCode));
        }