Skip to content

Commit 8906367

Browse files
committed
Initial Commit
0 parents  commit 8906367

24 files changed

+786
-0
lines changed

.gitignore

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
2+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3+
4+
# User-specific stuff
5+
.idea/**/workspace.xml
6+
.idea/**/tasks.xml
7+
.idea/**/usage.statistics.xml
8+
.idea/**/dictionaries
9+
.idea/**/shelf
10+
11+
# AWS User-specific
12+
.idea/**/aws.xml
13+
14+
# Generated files
15+
.idea/**/contentModel.xml
16+
17+
# Sensitive or high-churn files
18+
.idea/**/dataSources/
19+
.idea/**/dataSources.ids
20+
.idea/**/dataSources.local.xml
21+
.idea/**/sqlDataSources.xml
22+
.idea/**/dynamic.xml
23+
.idea/**/uiDesigner.xml
24+
.idea/**/dbnavigator.xml
25+
26+
# Gradle
27+
.idea/**/gradle.xml
28+
.idea/**/libraries
29+
30+
# Gradle and Maven with auto-import
31+
# When using Gradle or Maven with auto-import, you should exclude module files,
32+
# since they will be recreated, and may cause churn. Uncomment if using
33+
# auto-import.
34+
# .idea/artifacts
35+
# .idea/compiler.xml
36+
# .idea/jarRepositories.xml
37+
# .idea/modules.xml
38+
# .idea/*.iml
39+
# .idea/modules
40+
# *.iml
41+
# *.ipr
42+
43+
# CMake
44+
cmake-build-*/
45+
46+
# Mongo Explorer plugin
47+
.idea/**/mongoSettings.xml
48+
49+
# File-based project format
50+
*.iws
51+
52+
# IntelliJ
53+
out/
54+
55+
# mpeltonen/sbt-idea plugin
56+
.idea_modules/
57+
58+
# JIRA plugin
59+
atlassian-ide-plugin.xml
60+
61+
# Cursive Clojure plugin
62+
.idea/replstate.xml
63+
64+
# SonarLint plugin
65+
.idea/sonarlint/
66+
67+
# Crashlytics plugin (for Android Studio and IntelliJ)
68+
com_crashlytics_export_strings.xml
69+
crashlytics.properties
70+
crashlytics-build.properties
71+
fabric.properties
72+
73+
# Editor-based Rest Client
74+
.idea/httpRequests
75+
76+
# Android studio 3.1+ serialized cache file
77+
.idea/caches/build_file_checksums.ser

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/description.html

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/project-template.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FileSystemImplementationWithJava.iml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.urunsiyabend.exceptions;
2+
3+
public class FileAlreadyExistsException extends Exception{
4+
public FileAlreadyExistsException() {
5+
super();
6+
}
7+
8+
public FileAlreadyExistsException(String message) {
9+
super(message);
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.urunsiyabend.exceptions;
2+
3+
public class FileComponentNotFoundException extends Exception {
4+
public FileComponentNotFoundException() {
5+
super();
6+
}
7+
8+
public FileComponentNotFoundException(String message) {
9+
super(message);
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.urunsiyabend.exceptions;
2+
3+
public class GroupNotFoundException extends Exception {
4+
5+
public GroupNotFoundException() {
6+
super();
7+
}
8+
9+
public GroupNotFoundException(String message) {
10+
super(message);
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.urunsiyabend.exceptions;
2+
3+
public class UserNotExistInGroupException extends Exception{
4+
public UserNotExistInGroupException() {
5+
super();
6+
}
7+
8+
public UserNotExistInGroupException(String message) {
9+
super(message);
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.urunsiyabend.exceptions;
2+
3+
public class UserNotFoundException extends Exception{
4+
public UserNotFoundException() {
5+
super();
6+
}
7+
8+
public UserNotFoundException(String message) {
9+
super(message);
10+
}
11+
}
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.urunsiyabend.fs;
2+
3+
import com.urunsiyabend.exceptions.FileAlreadyExistsException;
4+
import com.urunsiyabend.exceptions.FileComponentNotFoundException;
5+
6+
import java.util.ArrayList;
7+
8+
public class Directory extends FileComponent {
9+
private final ArrayList<FileComponent> fcs;
10+
11+
public Directory(String name, int diskSize, int ownerID, int groupOwnerID) {
12+
super(name, diskSize, ownerID, groupOwnerID);
13+
fcs = new ArrayList<>();
14+
}
15+
16+
@Override
17+
public void insert(FileComponent f) throws FileAlreadyExistsException {
18+
for (FileComponent fc : fcs) {
19+
if (fc.getName().equals(f.getName())) {
20+
throw new FileAlreadyExistsException("A file already exists with same name");
21+
}
22+
}
23+
f.setPath(this.getPath() + "/" + f.getName());
24+
fcs.add(f);
25+
}
26+
27+
@Override
28+
public void remove(FileComponent f) throws FileComponentNotFoundException, UnsupportedOperationException {
29+
if (!fcs.contains(f)) {
30+
throw new FileComponentNotFoundException("File does not exists!");
31+
}
32+
33+
fcs.remove(f);
34+
}
35+
36+
@Override
37+
public FileComponent child(int i) {
38+
return fcs.get(i);
39+
}
40+
41+
@Override
42+
public int find(FileComponent f) {
43+
return fcs.indexOf(f);
44+
}
45+
46+
public void display() {
47+
System.out.println(this);
48+
_displayChildren();
49+
}
50+
51+
protected void _displayChildren() {
52+
for (FileComponent fc : fcs) {
53+
System.out.print("-");
54+
System.out.println(fc);
55+
if (fc instanceof Directory) {
56+
fc._displayChildren();
57+
}
58+
}
59+
}
60+
61+
@Override
62+
public String toString() {
63+
return "Directory: " + super.toString();
64+
}
65+
}

src/com/urunsiyabend/fs/File.java

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.urunsiyabend.fs;
2+
3+
public class File extends FileComponent{
4+
5+
public File(String name, int diskSize, int ownerID, int groupOwnerID) {
6+
super(name, diskSize, ownerID, groupOwnerID);
7+
}
8+
9+
public void display() {
10+
System.out.println(this);
11+
}
12+
13+
@Override
14+
public String toString() {
15+
return "File: " + super.toString();
16+
}
17+
}

0 commit comments

Comments
 (0)