exists() private method

private exists ( ) : bool
return bool
Exemplo n.º 1
0
 public virtual void run()
 {
   Exception exception;
   try
   {
     ((Window) main.access\u0024000()).pack();
     ((Window) main.access\u0024000()).setVisible(true);
     this.val\u0024monitor.setProgress(750);
     this.val\u0024monitor.setNote("Loading From Save");
     File.__\u003Cclinit\u003E();
     File file = new File((string) main.access\u0024000().getPrefs().__\u003C\u003EsaveFile.getValue());
     if (file.exists())
       main.access\u0024000().load(file.getPath());
     this.val\u0024monitor.setProgress(1000);
     return;
   }
   catch (Exception ex)
   {
     int num = 0;
     M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num);
     if (m0 == null)
       throw;
     else
       exception = (Exception) m0;
   }
   Throwable.instancehelper_printStackTrace((Exception) exception);
   System.exit(1);
 }
Exemplo n.º 2
0
        private void recordBtn_Click(object sender, EventArgs e)
        {
            if (setMode)
            {
                try
                {
                    String filename = "Class" + LoginForm.classSec + "_kidWordAudio/test.wav";
                    recordBtn.Text       = "STOP";
                    wavSource            = new NAudio.Wave.WaveIn();
                    wavSource.WaveFormat = new NAudio.Wave.WaveFormat(44100, 1);

                    wavSource.DataAvailable    += new EventHandler <NAudio.Wave.WaveInEventArgs>(wavSource_DataAvail);
                    wavSource.RecordingStopped += new EventHandler <NAudio.Wave.StoppedEventArgs>(wavSource_RecordingStop);

                    wavFile = new NAudio.Wave.WaveFileWriter(filename, wavSource.WaveFormat);
                    wavSource.StartRecording();
                    setMode = false;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            else
            {
                //When you press "STOP", it automatically compares
                wavSource.StopRecording();

                String recordWAV_file = "Class" + LoginForm.classSec + "_kidWordAudio/test.wav";
                String refWAV_file    = "Class" + LoginForm.classSec + "_kidWordAudio/" + levels[curPos] + ";.wav";

                java.io.File f1 = new java.io.File(recordWAV_file);
                java.io.File f2 = new java.io.File(refWAV_file);

                if (!f1.exists() || !f2.exists())
                {
                    MessageBox.Show("WARNING: One of the files might be missing!");
                }
                else
                {
                    float compute_Result = compareAudio(recordWAV_file, refWAV_file);
                    if (compute_Result >= 10.0)
                    {
                        MessageBox.Show("Matched: " + compute_Result.ToString() + "\n You Win !");
                    }
                    else
                    {
                        MessageBox.Show("Matched: " + compute_Result.ToString() + "\n Try Again !");
                    }
                }
                recordBtn.Text = "RECORD";
                setMode        = true;
            }
        }
Exemplo n.º 3
0
        //Timer event
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            time--;
            CountDownBlk.Text = string.Format("0{0}:{1}", time / 60, time % 60);
            if (time < 5)
            {
                if (time % 2 == 0)
                {
                    CountDownBlk.Foreground = Brushes.Red;
                }
                else
                {
                    CountDownBlk.Foreground = Brushes.DarkRed;
                }
            }

            if (time == 0)
            {
                dispatcherTimer.Stop();
                wavSource.StopRecording();
                polyLine.Points.Clear();
                ReadAudioForm3.backButton.Enabled   = true;
                ReadAudioForm3.submitButton.Enabled = true;
                ReadAudioForm3.ActiveForm.Size      = new System.Drawing.Size(322, 400);

                //The recorded voice of the student
                String recordWAV_file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\RecordWAV\" + lvlStr + ".wav";
                //The reference sample of the teacher
                String refWAV_file = "Class" + LoginForm.classSec + "_kidAudio/" + lvlStr.ToLower() + ".wav";

                java.io.File f1 = new java.io.File(recordWAV_file);
                java.io.File f2 = new java.io.File(refWAV_file);

                //compare
                if (!f1.exists() || !f2.exists())
                {
                    MessageBox.Show("WARNING: One of the files might be missing!");
                }
                else
                {
                    CallCompareAudio(recordWAV_file, refWAV_file);
                }


                //MessageBox.Show("DONE");
                time = 10;
            }
        }
Exemplo n.º 4
0
 public PropertyManager(File file)
 {
     serverProperties = new Properties();
     serverPropertiesFile = file;
     if (file.exists())
     {
         try
         {
             serverProperties.load(new FileInputStream(file));
         }
         catch (Exception exception)
         {
             logger.log(Level.WARNING, (new StringBuilder()).append("Failed to load ").append(file).toString(),
                        exception);
             generateNewProperties();
         }
     }
     else
     {
         logger.log(Level.WARNING, (new StringBuilder()).append(file).append(" does not exist").toString());
         generateNewProperties();
     }
 }
Exemplo n.º 5
0
 public static File findFileOnClassPath(string name)
 {
   StringTokenizer stringTokenizer = new StringTokenizer(System.getProperty("java.class.path"), System.getProperty("path.separator"));
   while (stringTokenizer.hasMoreTokens())
   {
     File file1 = new File(stringTokenizer.nextToken());
     File absoluteFile = file1.getAbsoluteFile();
     if (absoluteFile.isFile())
     {
       File.__\u003Cclinit\u003E();
       File file2 = new File(absoluteFile.getParent(), name);
       if (file2.exists())
         return file2;
     }
     else
     {
       File file2 = new File(file1, name);
       if (file2.exists())
         return file2;
     }
   }
   return (File) null;
 }
Exemplo n.º 6
0
        public RegionFile(File file)
        {
            lastModified = 0L;
            fileName = file;
            debugln((new StringBuilder()).append("REGION LOAD ").append(fileName).toString());
            sizeDelta = 0;
            try
            {
                if (file.exists())
                {
                    lastModified = file.lastModified();
                }
                dataFile = new RandomAccessFile(file, "rw");
                if (dataFile.length() < 4096L)
                {
                    for (int i = 0; i < 1024; i++)
                    {
                        dataFile.writeInt(0);
                    }

                    for (int j = 0; j < 1024; j++)
                    {
                        dataFile.writeInt(0);
                    }

                    sizeDelta += 8192;
                }
                if ((dataFile.length() & 4095L) != 0L)
                {
                    for (int k = 0; k < (dataFile.length() & 4095L); k++)
                    {
                        dataFile.write(0);
                    }
                }
                int l = (int) dataFile.length()/4096;
                sectorFree = new ArrayList(l);
                for (int i1 = 0; i1 < l; i1++)
                {
                    sectorFree.add(Boolean.valueOf(true));
                }

                sectorFree.set(0, Boolean.valueOf(false));
                sectorFree.set(1, Boolean.valueOf(false));
                dataFile.seek(0L);
                for (int j1 = 0; j1 < 1024; j1++)
                {
                    int l1 = dataFile.readInt();
                    offsets[j1] = l1;
                    if (l1 == 0 || (l1 >> 8) + (l1 & 0xff) > sectorFree.size())
                    {
                        continue;
                    }
                    for (int j2 = 0; j2 < (l1 & 0xff); j2++)
                    {
                        sectorFree.set((l1 >> 8) + j2, Boolean.valueOf(false));
                    }
                }

                for (int k1 = 0; k1 < 1024; k1++)
                {
                    int i2 = dataFile.readInt();
                    chunkTimestamps[k1] = i2;
                }
            }
            catch (IOException ioexception)
            {
                ioexception.printStackTrace();
            }
        }
		private void saveBytecode(String className, byte[] bytecode) {
			var generatedPath = PathHelper.combine(System.getProperty("user.dir"), "Tests/resources/TypeBuilderTest/stab");
			var generatedDir = new File(generatedPath);
			if (!generatedDir.exists()) {
				generatedDir.mkdir();
			}
			var stream = new FileOutputStream(PathHelper.combine(generatedPath, className + ".class"));
			stream.write(bytecode);
			stream.close();
		}
Exemplo n.º 8
0
        //Compare
        private void compareBtn_Click(object sender, EventArgs e)
        {
            //string file1 = @"C:\Users\Abdush Shakoor\Desktop\S.wav";
            //This is the user's input
            string file1 = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\RecordWAV\" + lvlStr + ".wav";
            //This is the reference voice used to compare
            string file2 = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\TeacherWAV\" + lvlStr.ToLower() + ".wav";

            java.io.File f1 = new java.io.File(file1);
            java.io.File f2 = new java.io.File(file2);

            //If the files are missing or if they don't exist, give a "file is missing" error
            if (file1 == null || file2 == null || !f1.exists() || !f2.exists())
            {
                MessageBox.Show("Warning: No audio files are detected!");
            }
            else
            {
                //Compare the audio files
                float compRes = compareAudio(file1, file2);
                compareLabel.Text = "Match: " + compRes.ToString();

                if (compRes >= 25.0)
                {
                    MessageBox.Show("You win ! :D !");

                    //If user wins, update level and display choice
                    DialogResult diagRes = MessageBox.Show("Do you want to proceed or try again?", "important", MessageBoxButtons.YesNo);
                    if (diagRes == DialogResult.Yes)
                    {
                        this.Hide();
                        //Create a method that says "solved" after each level on the button -- will update it soon !
                        //xxxxxxxx

                        //If colorblind, change theme and go to new level
                        if (isColorBlind == true)
                        {
                            updateLevelProgress();
                            newLevel(isColorBlind);
                            saveLevelProgress(lvlStr);
                        }
                        //otherwise, revert old theme and go to new level
                        else
                        {
                            updateLevelProgress();
                            newLevel(isColorBlind);
                            saveLevelProgress(lvlStr);
                        }
                    }
                    //Otherwise, you can try again!!
                    else if (diagRes == DialogResult.No)
                    {
                        this.Hide();
                        if (isColorBlind == true)
                        {
                            repeatLevel(isColorBlind);
                        }
                        else
                        {
                            repeatLevel(isColorBlind);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Try again ! :(");
                }
            }
        }
        public void GetEXIF(string path, Action<string> yield)
        {

            var is_io = path.StartsWith(io);
            var is_thumb = path.StartsWith(thumb);

            var filepath = path.SkipUntilIfAny(io);

            if (is_thumb)
            {
                filepath = path.SkipUntilIfAny(thumb);
            }

            // is this still a problem?
            filepath = filepath.Replace("%20", " ");

            var file = new File(filepath);


            if (file.exists())
                if (file.isFile())
                    if (path.EndsWith(".jpg"))
                    {

                        //file.print(yield);

                    }
        }
Exemplo n.º 10
0
 public virtual void func_22094_a(WorldInfo worldinfo)
 {
     NBTTagCompound nbttagcompound = worldinfo.func_22185_a();
     var nbttagcompound1 = new NBTTagCompound();
     nbttagcompound1.setTag("Data", nbttagcompound);
     try
     {
         var file = new File(field_22099_b, "level.dat_new");
         var file1 = new File(field_22099_b, "level.dat_old");
         var file2 = new File(field_22099_b, "level.dat");
         CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound1, new FileOutputStream(file));
         if (file1.exists())
         {
             file1.delete();
         }
         file2.renameTo(file1);
         if (file2.exists())
         {
             file2.delete();
         }
         file.renameTo(file2);
         if (file.exists())
         {
             file.delete();
         }
     }
     catch (Exception exception)
     {
         exception.printStackTrace();
     }
 }
Exemplo n.º 11
0
 public virtual void readPlayerData(EntityPlayer entityplayer)
 {
     try
     {
         var file = new File(worldFile,
                             (new StringBuilder()).append(entityplayer.username).append(".dat").toString());
         if (file.exists())
         {
             NBTTagCompound nbttagcompound = CompressedStreamTools.func_770_a(new FileInputStream(file));
             if (nbttagcompound != null)
             {
                 entityplayer.readFromNBT(nbttagcompound);
             }
         }
     }
     catch (Exception)
     {
         logger.warning(
             (new StringBuilder()).append("Failed to load player data for ").append(entityplayer.username).
                 toString());
     }
 }
Exemplo n.º 12
0
    public static void findExtensions(ProgressMonitor monitor, int min, int max)
    {
      monitor.setNote("Loading Extensions");
      File file1 = new File("./extensions");
      File file2 = new File("./lib");
      File file3 = new File("./extensions/lib");
      URLClassLoader urlClassLoader1 = (URLClassLoader) ClassLoader.getSystemClassLoader(FileSniffer.__\u003CGetCallerID\u003E());
      Class class1 = (Class) ClassLiteral<URLClassLoader>.Value;
      Method declaredMethod;
      Exception exception1;
      try
      {
        Class class2 = class1;
        string str = "addURL";
        Class[] classArray = new Class[1];
        int index = 0;
        // ISSUE: variable of the null type
        __Null local = ClassLiteral<URL>.Value;
        classArray[index] = (Class) local;
        CallerID callerId = FileSniffer.__\u003CGetCallerID\u003E();
        declaredMethod = class2.getDeclaredMethod(str, classArray, callerId);
        ((AccessibleObject) declaredMethod).setAccessible(true);
        goto label_6;
      }
      catch (Exception ex)
      {
        int num = 0;
        M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num);
        if (m0 == null)
          throw;
        else
          exception1 = (Exception) m0;
      }
      Throwable.instancehelper_printStackTrace((Exception) exception1);
      monitor.setProgress(max);
      return;
label_6:
      File[] fileArray1 = new File[3];
      int index1 = 0;
      File file4 = file2;
      fileArray1[index1] = file4;
      int index2 = 1;
      File file5 = file3;
      fileArray1[index2] = file5;
      int index3 = 2;
      File file6 = file1;
      fileArray1[index3] = file6;
      File[] fileArray2 = fileArray1;
      int length1 = fileArray2.Length;
      for (int index4 = 0; index4 < length1; ++index4)
      {
        File file7 = fileArray2[index4];
        if (!file7.exists())
        {
          monitor.setProgress(min + (max - min) / 5);
        }
        else
        {
          System.get_out().println(new StringBuilder().append("Searching Folder:").append((object) file7).toString());
          monitor.setNote(new StringBuilder().append("Searching Folder:").append((object) file7).toString());
          File[] fileArray3 = file7.listFiles((FilenameFilter) new FileSniffer\u00241());
          if (fileArray3 == null)
          {
            monitor.setProgress(min + (max - min) / 5);
          }
          else
          {
            File[] fileArray4 = fileArray3;
            int length2 = fileArray4.Length;
            for (int index5 = 0; index5 < length2; ++index5)
            {
              File file8 = fileArray4[index5];
              System.get_out().println(new StringBuilder().append("Adding Jar:").append((object) file8).toString());
              Exception exception2;
              try
              {
                Method method = declaredMethod;
                URLClassLoader urlClassLoader2 = urlClassLoader1;
                object[] objArray = new object[1];
                int index6 = 0;
                URL url = file8.toURI().toURL();
                objArray[index6] = (object) url;
                CallerID callerId = FileSniffer.__\u003CGetCallerID\u003E();
                method.invoke((object) urlClassLoader2, objArray, callerId);
                continue;
              }
              catch (Exception ex)
              {
                int num = 0;
                M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num);
                if (m0 == null)
                  throw;
                else
                  exception2 = (Exception) m0;
              }
              Throwable.instancehelper_printStackTrace((Exception) exception2);
            }
            monitor.setProgress(min + (max - min) / 5);
          }
        }
      }
      if (!file1.exists())
      {
        System.get_out().println("No Extension Folder");
        monitor.setProgress(max);
      }
      else
      {
        File[] fileArray3 = file1.listFiles((FilenameFilter) new FileSniffer\u00242());
        double num1 = 0.0;
        File[] fileArray4 = fileArray3;
        int length2 = fileArray4.Length;
label_26:
        for (int index4 = 0; index4 < length2; ++index4)
        {
          File file7 = fileArray4[index4];
          System.get_out().println(new StringBuilder().append("Searching Jar:").append((object) file7).toString());
          monitor.setProgress(ByteCodeHelper.d2i((double) (min + max) / 2.0 * (1.0 + num1++ / (double) fileArray3.Length)));
          monitor.setNote(new StringBuilder().append("Searching Jar:").append((object) file7).toString());
          Enumeration enumeration;
          Exception exception2;
          try
          {
            enumeration = new JarFile(file7).entries();
            goto label_31;
          }
          catch (Exception ex)
          {
            int num2 = 0;
            exception2 = (Exception) ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num2);
          }
          Exception exception3 = exception2;
          goto label_52;
label_31:
          Exception exception4;
          Exception exception5;
          while (true)
          {
            Class class2;
            try
            {
              string name;
              do
              {
                if (enumeration.hasMoreElements())
                  name = ((ZipEntry) enumeration.nextElement()).getName();
                else
                  goto label_26;
              }
              while (!String.instancehelper_endsWith(name, ".class"));
              class2 = (Class) null;
              try
              {
                try
                {
                  try
                  {
                    class2 = Class.forName(String.instancehelper_replaceAll(String.instancehelper_substring(name, 0, String.instancehelper_length(name) - 6), "/", "."), false, (ClassLoader) urlClassLoader1, FileSniffer.__\u003CGetCallerID\u003E());
                    DisplayElementRegistry.registerWidget(class2.asSubclass((Class) ClassLiteral<Widget>.Value));
                    System.get_out().println(new StringBuilder().append("Custom Widget:").append(class2.getSimpleName()).toString());
                    continue;
                  }
                  catch (Exception ex)
                  {
                    int num2 = 2;
                    if (ByteCodeHelper.MapException<ClassCastException>(ex, (ByteCodeHelper.MapFlags) num2) == null)
                      throw;
                  }
                }
                catch (ClassNotFoundException ex)
                {
                  goto label_42;
                }
              }
              catch (Exception ex)
              {
                int num2 = 2;
                if (ByteCodeHelper.MapException<NoClassDefFoundError>(ex, (ByteCodeHelper.MapFlags) num2) == null)
                  throw;
                else
                  goto label_43;
              }
            }
            catch (Exception ex)
            {
              int num2 = 0;
              exception4 = (Exception) ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num2);
              break;
            }
            try
            {
              try
              {
                DisplayElementRegistry.registerStaticWidget(class2.asSubclass((Class) ClassLiteral<StaticWidget>.Value));
                System.get_out().println(new StringBuilder().append("Custom Static Widget:").append(class2.getSimpleName()).toString());
              }
              catch (Exception ex)
              {
                int num2 = 2;
                if (ByteCodeHelper.MapException<ClassCastException>(ex, (ByteCodeHelper.MapFlags) num2) == null)
                  throw;
              }
            }
            catch (Exception ex)
            {
              int num2 = 0;
              exception5 = (Exception) ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num2);
              goto label_51;
            }
            continue;
label_42:
            continue;
label_43:;
          }
          exception3 = exception4;
          goto label_52;
label_51:
          exception3 = exception5;
label_52:
          Throwable.instancehelper_printStackTrace(exception3);
          System.get_out().println("Error, could not add URL to system classloader");
        }
        monitor.setProgress(max);
      }
    }
		private void doTest(String test, LambdaExpression lambda) {
			variables = new ArrayList<VariableExpression>();
			labels = new ArrayList<Label>();
			switchLabels = new ArrayList<SwitchLabel>();
			
			var result = lambdaToString(lambda);
			
			var userDir = System.getProperty("user.dir");
			var generatedPath = PathHelper.combine(userDir, "tests/resources/ExpressionTreesTest/generated");
			var generatedDir = new File(generatedPath);
			if (!generatedDir.exists()) {
				generatedDir.mkdir();
			}
			var fileWriter = new FileWriter(PathHelper.combine(generatedPath, test + ".txt"));
			fileWriter.write(result);
			fileWriter.close();
		
			var referencePath = PathHelper.combine(PathHelper.combine(userDir, "tests/resources/ExpressionTreesTest/references"), test + ".txt");
			var referenceFile = new File(referencePath);
			String reference = null;
			if (referenceFile.exists()) {
				var fileReader = new InputStreamReader(new FileInputStream((referencePath)), Charset.forName("UTF-8"));
				reference = readToEnd(fileReader);
			} else {
				Assert.fail("No reference for '" + test + "'");
			}
			
			if (reference != null) {
				var genReader = new BufferedReader(new StringReader(result));
				var refReader = new BufferedReader(new StringReader(reference));
				for (;;) {
					var genLine = genReader.readLine();
					var refLine = refReader.readLine();
					if (genLine == null && refLine == null) {
						break;
					}
					Assert.assertEquals(refLine, genLine);
				}
			}
		}
		private void doTest(String test, TypeInfo typeInfo) {
			String result = typeToString(typeInfo, "");
			
			var userDir = System.getProperty("user.dir");
			var generatedPath = PathHelper.combine(userDir, "Tests/resources/TypeSystemTest/generated");
			var generatedDir = new File(generatedPath);
			if (!generatedDir.exists()) {
				generatedDir.mkdir();
			}
			var fileWriter = new FileWriter(PathHelper.combine(generatedPath, test + ".txt"));
			fileWriter.write(result);
			fileWriter.close();
			
			var expectedPath = PathHelper.combine(userDir, "Tests/resources/TypeSystemTest/expected");
			var expectedFile = new File(PathHelper.combine(expectedPath, test + ".txt"));
			Assert.assertTrue("Expected file not found: " + expectedFile, expectedFile.exists());
			var fileReader = new InputStreamReader(new FileInputStream((expectedFile)), Charset.forName("UTF-8"));
			var reference = readToEnd(fileReader);
			
			var genReader = new BufferedReader(new StringReader(result));
			var refReader = new BufferedReader(new StringReader(reference));
			for (;;) {
				var genLine = genReader.readLine();
				var refLine = refReader.readLine();
				if (genLine == null && refLine == null) {
					break;
				}
				Assert.assertEquals(refLine, genLine);
			}
		}
Exemplo n.º 15
0
 public static void main(string[] args)
 {
   string[] strArray = args;
   int length = strArray.Length;
   for (int index = 0; index < length; ++index)
   {
     File file = new File(strArray[index]);
     while (file.exists())
     {
       if (!file.delete())
       {
         try
         {
           Thread.sleep(100L);
         }
         catch (InterruptedException ex)
         {
         }
       }
       else
         break;
     }
   }
 }
Exemplo n.º 16
0
    public static File extractResource(Class cls, string name, File directory, string prefix, string suffix)
    {
      InputStream resourceAsStream = cls.getResourceAsStream(name);
      if (resourceAsStream == null)
        return (File) null;
      File file = (File) null;
      int num1 = 0;
      IOException ioException1;
      try
      {
        if (prefix == null && suffix == null)
        {
          File.__\u003Cclinit\u003E();
          file = new File(directory, new File(name).getName());
          num1 = file.exists() ? 1 : 0;
        }
        else
          file = File.createTempFile(prefix, suffix, directory);
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        byte[] numArray = new byte[resourceAsStream.available()];
        int num2;
        while ((num2 = resourceAsStream.read(numArray)) > 0)
          fileOutputStream.write(numArray, 0, num2);
        resourceAsStream.close();
        fileOutputStream.close();
        goto label_14;
      }
      catch (IOException ex)
      {
        int num2 = 1;
        ioException1 = (IOException) ByteCodeHelper.MapException<IOException>((Exception) ex, (ByteCodeHelper.MapFlags) num2);
      }
      IOException ioException2 = ioException1;
      if (file != null && num1 == 0)
        file.delete();
      throw Throwable.__\u003Cunmap\u003E((Exception) ioException2);
label_14:
      return file;
    }
        private bool handleArguments(String[] arguments) {
            parameters = new CompilerParameters();
            int i = 0;
            while (i < sizeof(arguments) && (arguments[i].startsWith("-"))) {
                int idx = arguments[i].indexOf(':');
                var argument = arguments[i].substring(1);
                var parameter = "";
                if (idx > 0) {
                    argument = arguments[i].substring(1, idx);
                    parameter = arguments[i].substring(idx + 1);
                }
                var option = Options[argument];
                if (option == null) {
                    System.out.println("Error: Unknown option: " + argument);
                    return false;
                }
                switch (option) {
                case Annotatedlibs: {
                    while (parameter.length() > 0) {
                        idx = parameter.indexOf(';');
                        String file;
                        if (idx >= 0) {
                            file = parameter.substring(0, idx);
                            parameter = parameter.substring(idx + 1);
                        } else {
                            file = parameter;
                            parameter = "";
                        }
                        if (!new File(file).exists()) {
                            System.out.println(MISSING_FILE + file);
                            return false;
                        }
                        parameters.AnnotatedLibraryPaths.add(file);
                    }
                    break;
                }
                case Classpath: {
                    while (parameter.length() > 0) {
                        idx = parameter.indexOf(';');
                        String file;
                        if (idx >= 0) {
                            file = parameter.substring(0, idx);
                            parameter = parameter.substring(idx + 1);
                        } else {
                            file = parameter;
                            parameter = "";
                        }
                        if (!new File(file).exists()) {
                            System.out.println(MISSING_FILE + file);
                            return false;
                        }
                        parameters.ClassPath.add(file);
                    }
                    break;
                }
                case Define: {
                    while (parameter.length() > 0) {
                        idx = parameter.indexOf(';');
                        if (idx >= 0) {
                            parameters.getSymbols().add(parameter.substring(0, idx));
                            parameter = parameter.substring(idx + 1);
                        } else {
                            parameters.getSymbols().add(parameter);
                            parameter = "";
                        }
                    }
                    break;
                }
                case Doc: {
                    parameters.DocumentationPath = parameter;
                    break;
                }
                case Manifest: {
                    manifestPath = parameter;
                    if (!new File(manifestPath).exists()) {
                        System.out.println(MISSING_FILE + manifestPath);
                        return false;
                    }
                    break;
                }
                case Out: {
                    outputPath = parameter;
                    break;
                }
                case Resources: {
                    resourcesPath = parameter;
                    break;
                }
                case Help: {
                    System.out.println("    Cnatural Compiler Options");
                    System.out.println();
                    foreach (var opt in OptionInfos) {
                        System.out.print("-");
                        System.out.print(opt.Name);
                        if (opt.Arguments != null) {
                            System.out.print(":");
                            System.out.print(opt.Arguments);
                        }
                        System.out.println();
                        System.out.print("\t");
                        System.out.print(opt.Description);
                        if (opt.ShortForm != null) {
                            System.out.print(" (Short form: -");
                            System.out.print(opt.ShortForm);
                            System.out.print(")");
                        }
                        System.out.println();
                        System.out.println();
                    }
                    break;
                }
                }
                i++;
            }
            while (i < sizeof(arguments)) {
                File file = new File(arguments[i]);
                if (!file.exists()) {
                    System.out.println(MISSING_FILE + arguments[i]);
                    return false;
                }
                if (file.isDirectory()) {
                    System.out.println("Error: Argument is a directory: " + arguments[i]);
                    return false;
                }
                sourceFiles.add(file);
                i++;
            }
            if (sourceFiles.size() == 0) {
                System.out.println("Error: No input file");
                return false;
            }
            if (outputPath == null) {
                var absolutePath = sourceFiles[0].getAbsolutePath();
				var dir = PathHelper.getDirectoryName(absolutePath);
				var filename = PathHelper.getFileNameWithoutExtension((absolutePath.endsWith(".cs"))? PathHelper.getFileNameWithoutExtension(absolutePath) : absolutePath);
                outputPath = PathHelper.combine(dir, filename + ".jar");
            }
			System.out.println("Output: "+outputPath);
            return true;
        }
Exemplo n.º 18
0
        //Compare
        private void compareBtn_Click(object sender, EventArgs e)
        {
            //string file1 = @"C:\Users\Abdush Shakoor\Desktop\S.wav";
            //This is the user's input
            string file1 = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\RecordWAV\" + lvlStr + ".wav";
            //This is the reference voice used to compare
            string file2 = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\TeacherWAV\" + lvlStr.ToLower() + ".wav";

            java.io.File f1 = new java.io.File(file1);
            java.io.File f2 = new java.io.File(file2);

            //If the files are missing or if they don't exist, give a "file is missing" error
            if (file1 == null || file2 == null || !f1.exists() || !f2.exists())
            {
                MessageBox.Show("Warning: No audio files are detected!");
            }
            else
            {
                //Compare the audio files
                float compRes = compareAudio(file1, file2);
                compareLabel.Text = "Match: " + compRes.ToString();

                if (compRes >= 25.0)
                {
                    MessageBox.Show("You win ! :D !");

                    //If user wins, update level and display choice
                    DialogResult diagRes = MessageBox.Show("Do you want to proceed or try again?", "important", MessageBoxButtons.YesNo);
                    if (diagRes == DialogResult.Yes)
                    {
                        this.Hide();
                        //Create a method that says "solved" after each level on the button -- will update it soon !
                        //xxxxxxxx

                        //If colorblind, change theme and go to new level
                        if (isColorBlind == true)
                        {
                            updateLevelProgress();
                            newLevel(isColorBlind);
                            saveLevelProgress(lvlStr);
                        }
                        //otherwise, revert old theme and go to new level
                        else
                        {
                            updateLevelProgress();
                            newLevel(isColorBlind);
                            saveLevelProgress(lvlStr);
                        }
                    }
                    //Otherwise, you can try again!!
                    else if (diagRes == DialogResult.No)
                    {
                        this.Hide();
                        if (isColorBlind == true)
                        {
                            repeatLevel(isColorBlind);
                        }
                        else
                        {
                            repeatLevel(isColorBlind);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Try again ! :(");
                }
            }
        }
Exemplo n.º 19
0
 public virtual WorldInfo func_22096_c()
 {
     var file = new File(field_22099_b, "level.dat");
     if (file.exists())
     {
         try
         {
             NBTTagCompound nbttagcompound = CompressedStreamTools.func_770_a(new FileInputStream(file));
             NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
             return new WorldInfo(nbttagcompound1);
         }
         catch (Exception exception)
         {
             exception.printStackTrace();
         }
     }
     return null;
 }
Exemplo n.º 20
0
 private File chunkFileForXZ(int i, int j)
 {
     string s =
         (new StringBuilder()).append("c.").append(Integer.toString(i, 36)).append(".").append(
             Integer.toString(j, 36)).append(".dat").toString();
     string s1 = Integer.toString(i & 0x3f, 36);
     string s2 = Integer.toString(j & 0x3f, 36);
     var file = new File(saveDir, s1);
     if (!file.exists())
     {
         if (createIfNecessary)
         {
             file.mkdir();
         }
         else
         {
             return null;
         }
     }
     file = new File(file, s2);
     if (!file.exists())
     {
         if (createIfNecessary)
         {
             file.mkdir();
         }
         else
         {
             return null;
         }
     }
     file = new File(file, s);
     if (!file.exists() && !createIfNecessary)
     {
         return null;
     }
     else
     {
         return file;
     }
 }
Exemplo n.º 21
0
 public virtual void writePlayerData(EntityPlayer entityplayer)
 {
     try
     {
         var nbttagcompound = new NBTTagCompound();
         entityplayer.writeToNBT(nbttagcompound);
         var file = new File(worldFile, "_tmp_.dat");
         var file1 = new File(worldFile,
                              (new StringBuilder()).append(entityplayer.username).append(".dat").toString());
         CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound, new FileOutputStream(file));
         if (file1.exists())
         {
             file1.delete();
         }
         file.renameTo(file1);
     }
     catch (Exception)
     {
         logger.warning(
             (new StringBuilder()).append("Failed to save player data for ").append(entityplayer.username).
                 toString());
     }
 }
Exemplo n.º 22
0
        //The timer function
        //Once the timer is over, it'll display the result that was recorded during this period
        private void countTimer_Tick(object sender, EventArgs e)
        {
            //startRecord();
            seconds = seconds - 1;

            if (seconds == 0)
            {
                //When you press "STOP"
                //The recording and the counter are stopped
                //It then compares with the recorded audio and compares
                wavSource.StopRecording();
                countTimer.Stop();
                backBtn.Enabled = true;
                slideUp(sender, e);

                //The recorded voice of the student
                String recordWAV_file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\RecordWAV\" + lvlStr + ".wav";
                //The reference sample of the teacher
                String refWAV_file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\TeacherWAV\" + lvlStr.ToLower() + ".wav";

                java.io.File f1 = new java.io.File(recordWAV_file);
                java.io.File f2 = new java.io.File(refWAV_file);

                if (!f1.exists() || !f2.exists())
                {
                    MessageBox.Show("WARNING: One of the files might be missing!");
                }
                else
                {
                    float compute_Result = compareAudio(recordWAV_file, refWAV_file);
                    if (compute_Result >= 10.0)
                    {
                        MessageBox.Show("Matched: " + compute_Result.ToString() + "\n You Win !");
                        //If user wins, update level and display choice
                        DialogResult diagRes = MessageBox.Show("Do you want to proceed or try again?", "important", MessageBoxButtons.YesNo);
                        if (diagRes == DialogResult.Yes)
                        {
                            this.Hide();

                            //If colorblind, change theme and go to new level
                            if (isColorBlind == true)
                            {
                                updateLevelProgress();
                                newLevel(isColorBlind);
                                saveLevelProgress(lvlStr);
                            }
                            //otherwise, revert old theme and go to new level
                            else
                            {
                                updateLevelProgress();
                                newLevel(isColorBlind);
                                saveLevelProgress(lvlStr);
                            }
                        }
                        //Otherwise, you can try again!!
                        else if (diagRes == DialogResult.No)
                        {
                            this.Hide();
                            if (isColorBlind == true)
                            {
                                repeatLevel(isColorBlind);
                            }
                            else
                            {
                                repeatLevel(isColorBlind);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Matched: " + compute_Result.ToString() + "\n Try Again !");
                    }
                }

                //MessageBox.Show("DONE!");
                timeLabel.Visible = false;
                secsLabel.Visible = false;
            }
            secsLabel.Text = Convert.ToString(seconds);
        }
        // refactor this into separate partial class file
        public void Handler(WebServiceHandler h)
        {


            var path = h.Context.Request.Path;

            var is_io = path.StartsWith(io);
            var is_thumb = path.StartsWith(thumb);

            if (is_io || is_thumb)
            {


                var filepath = path.SkipUntilIfAny(io);

                if (is_thumb)
                {
                    filepath = path.SkipUntilIfAny(thumb);
                }

                // is this still a problem?
                filepath = filepath.Replace("%20", " ");

                var file = new File(filepath);


                if (file.exists())
                    if (file.isFile())
                        if (path.EndsWith(".jpg"))
                        {
                            var bytes = InternalReadBytes(filepath, is_thumb);

                            h.Context.Response.ContentType = "image/jpg";

                            // http://www.webscalingblog.com/performance/caching-http-headers-cache-control-max-age.html
                            h.Context.Response.AddHeader("Cache-Control", "max-age=2592000");

                            // send all the bytes

                            h.Context.Response.OutputStream.Write(bytes, 0, bytes.Length);



                            h.CompleteRequest();
                            return;
                        }

                h.Context.Response.ContentType = "text/html";
                h.Context.Response.Write("what ya lookin for?");
                h.Context.Response.Write(new XElement("pre", filepath).ToString());
                h.CompleteRequest();
                return;
            }
        }
        // refactor this into separate partial class file
        public void InternalHandler(WebServiceHandler h)
        {
            // HTTP routing? how to do this more elegantly?
            service.InternalHandler(h);

            var Host = h.Context.Request.Headers["Host"].TakeUntilIfAny(":");

            var path = h.Context.Request.Path;

            if (h.IsDefaultPath)
            {
                if (!h.Context.Request.QueryString.AllKeys.Contains("about"))
                    if (Host == h.Context.Request.UserHostAddress)
                    {
                        //h.Context.Response.SetCookie(new System.Web.HttpCookie("about", "me"));

                        //System.Console.WriteLine("open this in laptop");

                        h.Context.Response.Redirect("/?about=me");
                        h.CompleteRequest();

                        return;
                    }
            }



            var is_io = path.StartsWith(io);
            var is_thumb = path.StartsWith(thumb);

            if (is_io || is_thumb)
            {


                var filepath = path.SkipUntilIfAny(io);

                if (is_thumb)
                {
                    filepath = path.SkipUntilIfAny(thumb);
                }

                // is this still a problem?
                filepath = filepath.Replace("%20", " ");

#if Android
                var file = new File(filepath);


                if (file.exists())
                    if (file.isFile())
                        if (path.EndsWith(".jpg"))
                        {
                            var bytes = InternalReadBytes(filepath, is_thumb);

                            h.Context.Response.ContentType = "image/jpg";

                            // http://www.webscalingblog.com/performance/caching-http-headers-cache-control-max-age.html
                            h.Context.Response.AddHeader("Cache-Control", "max-age=2592000");

                            // send all the bytes

                            h.Context.Response.OutputStream.Write(bytes, 0, bytes.Length);



                            h.CompleteRequest();
                            return;
                        }
#endif


                h.Context.Response.ContentType = "text/html";
                h.Context.Response.Write("what ya lookin for?");
                h.Context.Response.Write(new XElement("pre", filepath).ToString());
                h.CompleteRequest();
                return;
            }
        }
Exemplo n.º 25
0
        //public static void WriteHexDumpFromFile(string filename)
        //{
        //    try
        //    {
        //        File file = new File(filename);

        //        RandomAccessFile stream = new RandomAccessFile(file, "r");

        //        sbyte[] bytes = new sbyte[stream.length()];

        //        stream.read(bytes);

        //        stream.close();

        //        System.Console.WriteLine("dump of [" + file + "]");
        //        Console.WriteHexDump(bytes);
        //    }
        //    catch (Exception exc)
        //    {

        //        Console.WriteThrowable(exc);
        //    }


        //}

        /// <summary>
        /// writes bytes to file
        /// </summary>
        /// <param name="cdata"></param>
        /// <param name="p"></param>
        public static void WriteBytes(sbyte[] cdata, string filename, bool utf8)
        {
            try
            {
                File f = new File(filename);

                if (f.exists())
                    f.delete();

                RandomAccessFile stream = new RandomAccessFile(filename, "rw");

                if (utf8)
                {
                    stream.writeByte(0xEF);
                    stream.writeByte(0xBB);
                    stream.writeByte(0xBF);
                }

                stream.write(cdata);

                stream.close();
            }
            catch
            {

            }
        }
Exemplo n.º 26
0
        //Record voice
        private void recordBtn_Click(object sender, EventArgs e)
        {
            if (setMode)
            {
                try
                {
                    String filename = @"C:\Pres_Proto\MetroFrameworkDLLExample\RecordWAV\" + letters[curPos] + ".wav";
                    recordBtn.Text = "STOP";
                    wavSource = new NAudio.Wave.WaveIn();
                    wavSource.WaveFormat = new NAudio.Wave.WaveFormat(44100, 1);

                    wavSource.DataAvailable += new EventHandler<NAudio.Wave.WaveInEventArgs>(wavSource_DataAvail);
                    wavSource.RecordingStopped += new EventHandler<NAudio.Wave.StoppedEventArgs>(wavSource_RecordingStop);

                    wavFile = new NAudio.Wave.WaveFileWriter(filename, wavSource.WaveFormat);
                    wavSource.StartRecording();
                    setMode = false;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            else
            {
                //When you press "STOP", it automatically compares
                wavSource.StopRecording();

                String recordWAV_file = @"C:\Pres_Proto\MetroFrameworkDLLExample\RecordWAV\" + letters[curPos] + ".wav";
                String refWAV_file = "Class" + LoginForm.classSec + "_kidAudio/" + letters[curPos] + ".wav";

                File f1 = new File(recordWAV_file);
                File f2 = new File(refWAV_file);

                if (!f1.exists() || !f2.exists())
                {
                    MessageBox.Show("WARNING: One of the files might be missing!");
                }
                else
                {
                    float compute_Result = compareAudio(recordWAV_file, refWAV_file);
                    if (compute_Result >= 10.0)
                    {
                        MessageBox.Show("Matched: " + compute_Result.ToString() + "\n You Win !");
                    }
                    else
                    {
                        MessageBox.Show("Matched: " + compute_Result.ToString() + "\n Try Again !");
                    }
                }
                recordBtn.Text = "RECORD";
                setMode = true;
            }
        }
Exemplo n.º 27
0
        //Timer event
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            time--;
            CountDownBlk.Text = string.Format("0{0}:{1}", time / 60, time % 60);
            if (time < 5)
            {
                if (time % 2 == 0)
                {
                    CountDownBlk.Foreground = Brushes.Red;
                }
                else
                {
                    CountDownBlk.Foreground = Brushes.DarkRed;
                }
            }

            if(time == 0)
            {
                dispatcherTimer.Stop();
                wavSource.StopRecording();
                polyLine.Points.Clear();
                ReadAudioForm3.backButton.Enabled = true;
                ReadAudioForm3.submitButton.Enabled = true;
                ReadAudioForm3.ActiveForm.Size = new System.Drawing.Size(322, 400);

                //The recorded voice of the student
                String recordWAV_file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\RecordWAV\" + lvlStr + ".wav";
                //The reference sample of the teacher
                String refWAV_file = "Class" + LoginForm.classSec + "_kidAudio/" + lvlStr.ToLower() + ".wav";

                java.io.File f1 = new java.io.File(recordWAV_file);
                java.io.File f2 = new java.io.File(refWAV_file);

                //compare
                if (!f1.exists() || !f2.exists())
                {
                    MessageBox.Show("WARNING: One of the files might be missing!");
                }
                else
                {
                    CallCompareAudio(recordWAV_file, refWAV_file);
                }

                //MessageBox.Show("DONE");
                time = 10;
            }
        }
		private void doTest(String test) {
			var userDir = System.getProperty("user.dir");
			var sourcePath = PathHelper.combine(PathHelper.combine(userDir, "tests/resources/ParseExpressionTest/sources"), test + ".txt");
			var fileReader = new InputStreamReader(new FileInputStream((sourcePath)), Charset.forName("UTF-8"));
			var code = readToEnd(fileReader);
			text = code.toCharArray();
			var parser = new Parser();
			var scanner = new SourceCodeScanner(new CodeErrorManager(), text);
			var expression = parser.parseExpression(scanner);
			var result = expressionToString(expression);
			
			var generatedPath = PathHelper.combine(userDir, "tests/resources/ParseExpressionTest/generated");
			var generatedDir = new File(generatedPath);
			if (!generatedDir.exists()) {
				generatedDir.mkdir();
			}
			var fileWriter = new FileWriter(PathHelper.combine(generatedPath, test + ".txt"));
			fileWriter.write(result);
			fileWriter.close();
			
			var expectedPath = PathHelper.combine(userDir, "tests/resources/ParseExpressionTest/expected");
			var expectedFile = new File(PathHelper.combine(expectedPath, test + ".txt"));
			Assert.assertTrue("Expected file not found: " + expectedFile, expectedFile.exists());
			fileReader = new InputStreamReader(new FileInputStream((expectedFile)), Charset.forName("UTF-8"));
			var reference = readToEnd(fileReader);
			
			var genReader = new BufferedReader(new StringReader(result));
			var refReader = new BufferedReader(new StringReader(reference));
			for (;;) {
				var genLine = genReader.readLine();
				var refLine = refReader.readLine();
				if (genLine == null && refLine == null) {
					break;
				}
				Assert.assertEquals(refLine, genLine);
			}
		}
        // how does this relate to SSL/ and ServiceWorker?
        public void Handler(WebServiceHandler h)
        {
            var io = "/io";
            var path = h.Context.Request.Path;
            if (path.StartsWith(io))
            {


                var filepath = path.SkipUntilIfAny(io);

                filepath = filepath.Replace("%20", " ");

                var file = new File(filepath);


                if (file.exists())
                    if (file.isFile())
                        if (path.EndsWith(".jpg"))
                        {
                            var bytes = System.IO.File.ReadAllBytes(filepath);

                            h.Context.Response.ContentType = "image/jpg";


                            // send all the bytes

                            h.Context.Response.OutputStream.Write(bytes, 0, bytes.Length);



                            h.CompleteRequest();
                            return;
                        }

                h.Context.Response.ContentType = "text/html";
                h.Context.Response.Write("what ya lookin for?");
                h.Context.Response.Write(new XElement("pre", filepath).ToString());
                h.CompleteRequest();
                return;
            }
        }
Exemplo n.º 30
0
        //The timer function
        //Once the timer is over, it'll display the result that was recorded during this period
        private void countTimer_Tick(object sender, EventArgs e)
        {
            //startRecord();
            seconds = seconds - 1;

            if (seconds == 0)
            {
                //When you press "STOP"
                //The recording and the counter are stopped
                //It then compares with the recorded audio and compares
                wavSource.StopRecording();
                countTimer.Stop();
                backBtn.Enabled = true;
                slideUp(sender, e);

                //The recorded voice of the student
                String recordWAV_file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\RecordWAV\" + lvlStr + ".wav";
                //The reference sample of the teacher
                String refWAV_file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\TeacherWAV\" + lvlStr.ToLower() + ".wav";

                java.io.File f1 = new java.io.File(recordWAV_file);
                java.io.File f2 = new java.io.File(refWAV_file);

                if (!f1.exists() || !f2.exists())
                {
                    MessageBox.Show("WARNING: One of the files might be missing!");
                }
                else
                {
                    float compute_Result = compareAudio(recordWAV_file, refWAV_file);
                    if (compute_Result >= 10.0)
                    {
                        MessageBox.Show("Matched: " + compute_Result.ToString() + "\n You Win !");
                        //If user wins, update level and display choice
                        DialogResult diagRes = MessageBox.Show("Do you want to proceed or try again?", "important", MessageBoxButtons.YesNo);
                        if (diagRes == DialogResult.Yes)
                        {
                            this.Hide();

                            //If colorblind, change theme and go to new level
                            if (isColorBlind == true)
                            {
                                updateLevelProgress();
                                newLevel(isColorBlind);
                                saveLevelProgress(lvlStr);
                            }
                            //otherwise, revert old theme and go to new level
                            else
                            {
                                updateLevelProgress();
                                newLevel(isColorBlind);
                                saveLevelProgress(lvlStr);
                            }
                        }
                        //Otherwise, you can try again!!
                        else if (diagRes == DialogResult.No)
                        {
                            this.Hide();
                            if (isColorBlind == true)
                            {
                                repeatLevel(isColorBlind);
                            }
                            else
                            {
                                repeatLevel(isColorBlind);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Matched: " + compute_Result.ToString() + "\n Try Again !");
                    }
                }

                //MessageBox.Show("DONE!");
                timeLabel.Visible = false;
                secsLabel.Visible = false;
            }
            secsLabel.Text = Convert.ToString(seconds);
        }