aboutsummaryrefslogtreecommitdiff
path: root/project/QBarInterpreter/src/com/modulus/qbar/core/QBFile.java
blob: 94b8a63217c2e331e5f97ba050f17d2d826983d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.modulus.qbar.core;

import java.io.File;

import com.modulus.qbar.core.interpreter.Main;

public class QBFile {
	private static String[] extensions = new String[]{"", ".qbz", ".qbc", ".qbar"};
	public static File getQBFile( String filename ){
		String[] folders = Main.getPath();
		
		if( folders == null )
			folders = new String[]{};
		
		File file = new File(filename);
		
		for(String path : folders){
		
			for(String str : extensions) {
				if(file.exists()) {
					Main.debug(QBFile.class, " Found File " + file + " on the classpath!");
					return file;	
				}
				
				
				file = new File(path, filename + str);
			//	Main.debug(QBFile.class, " Looking for File " + file.getAbsolutePath() + " on the classpath.");
			}
		}
		
		if(!file.exists())
			throw new RuntimeException("The file: " + filename + " cannot be found on the classpath!");
		
		return file;
	}
}