Exemplo n.º 1
0
    public static uint8_t read_file(string szFile)
    {
        ifstream   file = new ifstream(szFile, ios.binary | ios.ate);
        streamsize size = file.tellg();

        file.seekg(0, ios.beg);

        if (size == -1)
        {
            return(null);
        }

        uint8_t[] buffer = Arrays.InitializeWithDefaultInstances <uint8_t>(size);
        file.read((string)buffer, size);
        return(buffer);
    }
Exemplo n.º 2
0
//C++ TO C# CONVERTER WARNING: The original C++ declaration of the following method implementation was not found:
        public void LoadRules(string filename, bool quad)
        {
            string  buf = new string(new char[256]);
            istream ist;
            //char *tr1 = NULL;
            string tr1;

            /*
             * ifstream ist (filename);
             * if (!ist.good())
             * {
             *  cerr << "Rule description file " << filename << " not found" << endl;
             *  exit (1);
             * }
             */


            if (filename)
            {
                //      (*mycout) << "rule-filename = " << filename << endl;
                ist = new ifstream(filename);
            }
            else
            {
                /* connect tetrules to one string */
                string[] hcp;

                // if (!mparam.quad)
                if (!quad)
                {
                    hcp = triarules;
                    PrintMessage(3, "load internal triangle rules");
                }
                else
                {
                    hcp = quadrules;
                    PrintMessage(3, "load internal quad rules");
                    // LoadRules ("rules/quad.rls");
                }

                uint len = 0;
                while hcp
                {
                    //	  (*testout) << "POS2 *hcp " << *hcp << endl;
                    len += Convert.ToStringhcp.Length;
                    hcp++;
                }
                //tr1 = new char[len+1];
                //tr1[0] = 0;
                tr1.reserve(len + 1);


                // if (!mparam.quad)
                if (!quad)
                {
                    hcp = triarules;
                }
                else
                {
                    hcp = quadrules;
                }


                //char * tt1 = tr1;
                while hcp
                {
                    //strcat (tt1, *hcp);
                    //tt1 += strlen (*hcp);
                    tr1.appendhcp;
                    hcp++;
                }

                #if WIN32
                // VC++ 2005 workaround
                for (int i = 0; i < tr1.Length; i++)
                {
                    if (tr1[i] == ',')
                    {
                        tr1 = StringFunctions.ChangeCharacter(tr1, i, ':');
                    }
                }
                #endif

                ist = new istringstream(tr1);
            }


            if (!ist.good())
            {
                cerr << "Rule description file " << filename << " not found" << "\n";
                ist = null;
                Environment.Exit(1);
            }

            while (!ist.eof())
            {
                buf = null;
                ist >> buf;

                if (string.Compare(buf, "rule") == 0)
                {
                    //(*testout) << "found rule" << endl;
                    netrule rule = new netrule();
                    //(*testout) << "fr1" << endl;
                    rule.LoadRule(ist);
                    //(*testout) << "fr2" << endl;

                    rules.Append(rule);
                }
                //(*testout) << "loop" << endl;
            }
            //(*testout) << "POS3" << endl;

            ist = null;
            //delete [] tr1;
        }