53 |
|
{ |
54 |
|
static ext::String user("Douglas Thrift"), password(::getpass("Password:")); |
55 |
|
|
56 |
< |
::snprintf(un, unlen, "%s", user.NullTerminate()); |
57 |
< |
::snprintf(pw, pwlen, "%s", password.NullTerminate()); |
56 |
> |
_foreach (ext::String, atom, user) |
57 |
> |
un[_index] = *atom; |
58 |
> |
_foreach (ext::String, atom, password) |
59 |
> |
pw[_index] = *atom; |
60 |
> |
|
61 |
> |
un[user.GetSize() < size_t(unlen) ? user.GetSize() : unlen - 1] = '\0'; |
62 |
> |
pw[password.GetSize() < size_t(pwlen) ? password.GetSize() : pwlen - 1] = '\0'; |
63 |
|
} |
64 |
|
} |
65 |
|
|
80 |
|
|
81 |
|
void Syncify::syncify(const ext::String& local, const ext::String& remote) |
82 |
|
{ |
83 |
< |
Matcher dots("^\\.{1,2}$"); |
79 |
< |
ext::RedBlackSet<ext::String> directories; |
80 |
< |
int directory(CheckError(::smbc_opendir(remote.NullTerminate()))); |
81 |
< |
|
82 |
< |
for (::smbc_dirent* entity(::smbc_readdir(directory)); entity != NULL; entity = ::smbc_readdir(directory)) switch (entity->smbc_type) |
83 |
> |
try |
84 |
|
{ |
85 |
< |
case SMBC_FILE: |
86 |
< |
if (entity->name == pattern) |
85 |
> |
Matcher dots("^\\.{1,2}$"); |
86 |
> |
ext::RedBlackSet<ext::String> directories; |
87 |
> |
int directory(CheckError(::smbc_opendir(remote.NullTerminate()))); |
88 |
> |
|
89 |
> |
for (::smbc_dirent* entity(::smbc_readdir(directory)); entity != NULL; entity = ::smbc_readdir(directory)) switch (entity->smbc_type) |
90 |
|
{ |
91 |
< |
api::Cout << entity->name << ios::NewLine; |
91 |
> |
case SMBC_FILE: |
92 |
> |
if (entity->name == pattern) |
93 |
> |
{ |
94 |
> |
api::Cout << entity->name << ios::NewLine; |
95 |
> |
} |
96 |
> |
break; |
97 |
> |
case SMBC_DIR: |
98 |
> |
case SMBC_LINK: |
99 |
> |
if (entity->name != dots) |
100 |
> |
directories.Insert(entity->name); |
101 |
|
} |
89 |
– |
break; |
90 |
– |
case SMBC_DIR: |
91 |
– |
case SMBC_LINK: |
92 |
– |
if (entity->name != dots) |
93 |
– |
directories.Insert(entity->name); |
94 |
– |
} |
102 |
|
|
103 |
< |
::smbc_closedir(directory); |
103 |
> |
::smbc_closedir(directory); |
104 |
|
|
105 |
< |
_foreach (const ext::RedBlackSet<ext::String>, directory, directories) |
106 |
< |
syncify(local + "/" + *directory, remote + "/" + *directory); |
105 |
> |
_foreach (const ext::RedBlackSet<ext::String>, directory, directories) |
106 |
> |
syncify(local + "/" + *directory, remote + "/" + *directory); |
107 |
> |
} |
108 |
> |
catch (const Error& error) |
109 |
> |
{ |
110 |
> |
api::Cerr << error.GetMessage() << remote << ios::NewLine; |
111 |
> |
} |
112 |
|
} |