ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Syncify/Syncify.cpp
(Generate patch)

Comparing Syncify/Syncify.cpp (file contents):
Revision 436 by douglas, 2005-04-04T00:33:57-07:00 vs.
Revision 438 by douglas, 2005-04-05T16:14:43-07:00

# Line 51 | Line 51 | extern "C"
51   {
52          void authenticate(const char* srv, const char* shr, char* wg, int wglen, char* un, int unlen, char* pw, int pwlen)
53          {
54 <                static ext::String user("Douglas Thrift"), password(::getpass("Password:"));
54 >                static ext::Buffer user("Douglas Thrift"), password(::getpass("Password:"));
55  
56 <                ::snprintf(un, unlen, "%s", user.NullTerminate());
57 <                ::snprintf(pw, pwlen, "%s", password.NullTerminate());
56 >                _foreach (ext::Buffer, atom, user)
57 >                        un[_index] = *atom;
58 >                _foreach (ext::Buffer, 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  
# Line 75 | Line 80 | bool Syncify::debug(false);
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines