Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sgloutnikov/CS249-P1
Browse files Browse the repository at this point in the history
  • Loading branch information
sadib100 committed Mar 5, 2018
2 parents bb90dac + 39d3faf commit 2851c42
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
1 change: 1 addition & 0 deletions filesystem/test1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test1 file text
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ public static void main(final String[] args) throws RemoteException, NotBoundExc
break;
}

// this will list all the files on the server

case "ls": {

System.out.println("List files on the server");
Set<String> temp = serverService.listFiles(client1);
client1.listFiles(temp);

break;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/edu/sjsu/cs249/project1/server/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
Expand All @@ -13,7 +14,7 @@
*
* @author David Fisher
*/
public class File {
public class File implements Serializable {
/**
* Note: FILE_PATH_PREFIX is relative to your workspace installation directory.
*/
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/edu/sjsu/cs249/project1/server/FileServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,10 @@ public String version() {
*
*/
public Set<String> listFiles(ClientCallback client) throws RemoteException{
Set result=null;
FileSystem fileSystem=FileSystem.getInstance();
try {
result = fileSystem.listFiles();
} catch (FileException e) {
e.printStackTrace();
}
return result;
Set result = null;
FileSystem fileSystem = FileSystem.getInstance();
result = fileSystem.listFiles();
return result;
}

/**
Expand Down
15 changes: 2 additions & 13 deletions src/main/java/edu/sjsu/cs249/project1/server/FileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,8 @@ public void modifyFile(final String fileName, final byte[] newData) throws FileE
*
*
*/
public Set<String> listFiles() throws FileException {
Set result= null;
if (this.fileMap== null) {
System.out.println("Server hosts no files and can't list any. ");
}

//for (String filename: FileSystem.getInstance().getFileMap().keySet()) {
//System.out.println(filename +"\n");
else{
result = FileSystem.getInstance().getFileMap().keySet();
}

return result;
public Set<String> listFiles() {
return fileMap.keySet();
}

public Map<String, File> getFileMap() {
Expand Down

0 comments on commit 2851c42

Please sign in to comment.