-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Nexific/feature/#2_list_content_of_current…
…_directory Feature/#2 list content of current directory
- Loading branch information
Showing
6 changed files
with
174 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# IntelliJ | ||
.idea/ | ||
*.iml | ||
|
||
# Files and directories created by pub | ||
.dart_tool/ | ||
.packages | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
## 0.5.0 | ||
|
||
- | ||
- List files and directories in current directory | ||
|
||
## 0.4.0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
library ftpclient; | ||
|
||
export 'src/dto/FTPEnty.dart'; | ||
export 'src/ftpclient_base.dart'; | ||
export 'src/ftpexceptions.dart'; | ||
export 'src/transfermode.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import 'package:ftpclient/ftpclient.dart'; | ||
|
||
class FTPEntry { | ||
final String name; | ||
final DateTime modifyTime; | ||
final String persmission; | ||
final String type; | ||
final int size; | ||
final String unique; | ||
final String group; | ||
final String mode; | ||
final String owner; | ||
|
||
// Hide constructor | ||
FTPEntry._(this.name, this.modifyTime, this.persmission, this.type, this.size, | ||
this.unique, this.group, this.mode, this.owner); | ||
|
||
factory FTPEntry(final String sMlsdResponseLine) { | ||
if (sMlsdResponseLine == null || sMlsdResponseLine.trim().isEmpty) { | ||
throw FTPException('Can\'t create instance from empty information'); | ||
} | ||
|
||
String _name; | ||
DateTime _modifyTime; | ||
String _persmission; | ||
String _type; | ||
int _size = 0; | ||
String _unique; | ||
String _group; | ||
String _mode; | ||
String _owner; | ||
|
||
// Split and trim line | ||
sMlsdResponseLine.trim().split(';').forEach((property) { | ||
final prop = property | ||
.split('=') | ||
.map((part) => part.trim()) | ||
.toList(growable: false); | ||
|
||
if (prop.length == 1) { | ||
// Name | ||
_name = prop[0]; | ||
} else { | ||
// Other attributes | ||
switch (prop[0].toLowerCase()) { | ||
case 'modify': | ||
final String date = | ||
prop[1].substring(0, 8) + 'T' + prop[1].substring(8); | ||
_modifyTime = DateTime.parse(date); | ||
break; | ||
case 'perm': | ||
_persmission = prop[1]; | ||
break; | ||
case 'size': | ||
_size = int.parse(prop[1]); | ||
break; | ||
case 'type': | ||
_type = prop[1]; | ||
break; | ||
case 'unique': | ||
_unique = prop[1]; | ||
break; | ||
case 'unix.group': | ||
_group = prop[1]; | ||
break; | ||
case 'unix.mode': | ||
_mode = prop[1]; | ||
break; | ||
case 'unix.owner': | ||
_owner = prop[1]; | ||
break; | ||
default: | ||
throw FTPException('Unknown FTPEntry property \'$property\''); | ||
} | ||
} | ||
}); | ||
|
||
return FTPEntry._( | ||
_name, | ||
_modifyTime, | ||
_persmission, | ||
_type, | ||
_size, | ||
_unique, | ||
_group, | ||
_mode, | ||
_owner); | ||
} | ||
|
||
@override | ||
String toString() => | ||
'name=$name;modifyTime=$modifyTime;permission=$persmission;type=$type;size=$size;unique=$unique;group=$group;mode=$mode;owner=$owner'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters