Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2010-04-03 00:35:25 +0000
committereutarass2010-04-03 00:35:25 +0000
commit04dd39925f89339e9ac9b21ec32c19b3e1fa0ac0 (patch)
treebef70af33c96b73137fd7d7e0aea5865ca2b1176 /services/filesystem.c
parent1a2c01424930aecbade7c4219c7a2b04d6e3f2aa (diff)
downloadorg.eclipse.tcf.agent-04dd39925f89339e9ac9b21ec32c19b3e1fa0ac0.tar.gz
org.eclipse.tcf.agent-04dd39925f89339e9ac9b21ec32c19b3e1fa0ac0.tar.xz
org.eclipse.tcf.agent-04dd39925f89339e9ac9b21ec32c19b3e1fa0ac0.zip
TCF Agent: changed code for FileSystem.roots command on Windows to use GetLogicalDrives() to be able to report drives without media
Diffstat (limited to 'services/filesystem.c')
-rw-r--r--services/filesystem.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/services/filesystem.c b/services/filesystem.c
index b33059a5..edc21194 100644
--- a/services/filesystem.c
+++ b/services/filesystem.c
@@ -311,7 +311,7 @@ static void write_file_attrs(OutputStream * out, FileAttrs * attrs) {
json_write_long(out, attrs->gid);
cnt++;
}
- if (attrs->flags & ATTR_SIZE) {
+ if (attrs->flags & ATTR_PERMISSIONS) {
if (cnt) write_stream(out, ',');
json_write_string(out, "Permissions");
write_stream(out, ':');
@@ -1160,28 +1160,29 @@ static void command_roots(char * token, Channel * c) {
{
int cnt = 0;
int disk = 0;
- for (disk = 'A'; disk <= 'Z'; disk++) {
- char path[32];
- ULARGE_INTEGER freeBytesAvailable;
- ULARGE_INTEGER totalNumberOfBytes;
- ULARGE_INTEGER totalNumberOfFreeBytes;
- BOOL hasSize;
-
- snprintf(path, sizeof(path), "%c:/", disk);
- hasSize = GetDiskFreeSpaceExA(path, &freeBytesAvailable, &totalNumberOfBytes, &totalNumberOfFreeBytes);
- memset(&st, 0, sizeof(st));
- if (hasSize && stat(path, &st) == 0) {
- FileAttrs attrs;
+ DWORD disks = GetLogicalDrives();
+ for (disk = 0; disk <= 30; disk++) {
+ if (disks & (1 << disk)) {
+ char path[32];
+ snprintf(path, sizeof(path), "%c:/", 'A' + disk);
if (cnt > 0) write_stream(&c->out, ',');
write_stream(&c->out, '{');
json_write_string(&c->out, "FileName");
write_stream(&c->out, ':');
json_write_string(&c->out, path);
- fill_attrs(&attrs, &st);
- write_stream(&c->out, ',');
- json_write_string(&c->out, "Attrs");
- write_stream(&c->out, ':');
- write_file_attrs(&c->out, &attrs);
+ if (disk >= 2) {
+ ULARGE_INTEGER total_number_of_bytes;
+ BOOL has_size = GetDiskFreeSpaceExA(path, NULL, &total_number_of_bytes, NULL);
+ memset(&st, 0, sizeof(st));
+ if (has_size && stat(path, &st) == 0) {
+ FileAttrs attrs;
+ fill_attrs(&attrs, &st);
+ write_stream(&c->out, ',');
+ json_write_string(&c->out, "Attrs");
+ write_stream(&c->out, ':');
+ write_file_attrs(&c->out, &attrs);
+ }
+ }
write_stream(&c->out, '}');
cnt++;
}

Back to the top