// Copyright (c) 2013, Webit Team. All Rights Reserved.
package webit.script.loaders.impl.resources;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import webit.script.loaders.Resource;

/**
 *
 * @author Zqq
 */
public class FileResource implements Resource {

    private final String path;
    private final String encoding;
    private long lastLoadTime;

    public FileResource(String path, String encoding) {
        this.path = path;
        this.encoding = encoding;
    }

    public boolean isModified() {
        return lastLoadTime > new File(this.path).lastModified();
    }

    public Reader openReader() throws IOException {
        lastLoadTime = System.currentTimeMillis();
        final InputStream inputStream = new FileInputStream(this.path);

        return encoding == null
                ? new InputStreamReader(inputStream)
                : new InputStreamReader(inputStream, encoding);
    }
}

@@ -375,24 +375,26 @@
 urce %7B%0A%0A    
+//
 private fina
@@ -404,24 +404,53 @@
 tring path;%0A
+    private final File file;%0A
     private 
@@ -493,24 +493,24 @@
 ong last
-LoadTime
+Modified
 ;%0A%0A    p
@@ -564,24 +564,26 @@
 ) %7B%0A        
+//
 this.path = 
@@ -618,24 +618,60 @@
 = encoding;%0A
+        this.file = new File(path);%0A
     %7D%0A%0A    p
@@ -722,38 +722,24 @@
 last
-LoadTime %3E new File(this.path)
+Modified != file
 .las
@@ -826,95 +826,59 @@
 last
-LoadTime = System.currentTimeMillis();%0A        final InputStream inputStream =
+Modified = file.lastModified();%0A        return
  new 
-File
 Inpu
@@ -888,53 +888,15 @@
 ream
-(this.path);%0A%0A        return encoding == null
+Reader(
 %0A   
@@ -911,15 +911,17 @@
     
- ?
  new 
+File
 Inpu
@@ -931,80 +931,31 @@
 ream
-Reader(inputStream)%0A                : new InputStreamReader(inputStream,
+(file),%0A               
  enc

fix FileResource.isModified() misstake