diff --git a/src/shares.cpp b/src/shares.cpp index 39f1225d..0a8289f9 100644 --- a/src/shares.cpp +++ b/src/shares.cpp @@ -1,5 +1,6 @@ // SPDX-FileCopyrightText: 2023 Open Salamander Authors // SPDX-License-Identifier: GPL-2.0-or-later +// CommentsTranslationProject: TRANSLATED #include "precomp.h" #include @@ -17,8 +18,8 @@ CSharesItem::CSharesItem(const char* localPath, const char* remoteName, const ch { char buff[MAX_PATH]; lstrcpyn(buff, localPath, MAX_PATH); - SalPathAddBackslash(buff, MAX_PATH); // kdyby nahodou bylo jen "c:", tak aby vznikl root - if (SalGetFullName(buff)) // root "c:\\", ostatni bez '\\' na konci + SalPathAddBackslash(buff, MAX_PATH); // in case it was only "c:", make sure a root is created + if (SalGetFullName(buff)) // root "c\\", others without the trailing '\\' at the end { LocalPath = DupStr(buff); RemoteName = DupStr(remoteName); @@ -26,7 +27,7 @@ CSharesItem::CSharesItem(const char* localPath, const char* remoteName, const ch if (LocalPath != NULL && RemoteName != NULL && Comment != NULL) { char* s = strrchr(LocalPath, '\\'); - if (s == NULL || *(s + 1) == 0) // root cesta; s==NULL je pouze pro jistotu, ale nikdy nemuze vyjit + if (s == NULL || *(s + 1) == 0) // root path; s == NULL is only for safety, but it can never happen LocalName = LocalPath; else LocalName = s + 1; @@ -61,7 +62,7 @@ void CSharesItem::Cleanup() void CSharesItem::Destroy() { if (LocalPath != NULL) - free(LocalPath); // LocalName ukazuje do LocalPath, proto jej neuvolnujeme + free(LocalPath); // LocalName points into LocalPath, so we do not free it if (RemoteName != NULL) free(RemoteName); if (Comment != NULL) @@ -73,7 +74,7 @@ void CSharesItem::Destroy() // CShares // -/* Sekce nacteni sharu */ +/* Share loading section */ void CShares::Refresh() { @@ -96,9 +97,9 @@ void CShares::Refresh() char netname[MAX_PATH]; char path[MAX_PATH]; char remark[MAX_PATH]; - // special nechceme, protoze je Explorer neukazuje + // we do not want specials because Explorer does not show them BOOL include = p->shi502_type == 0; - if (!SubsetOnly && p->shi502_type == 0x80000000) // special + if (!SubsetOnly && p->shi502_type == 0x80000000) // special share include = TRUE; if (include && WideCharToMultiByte(CP_ACP, 0, p->shi502_netname, -1, netname, MAX_PATH, NULL, NULL) && @@ -106,19 +107,19 @@ void CShares::Refresh() WideCharToMultiByte(CP_ACP, 0, p->shi502_remark, -1, remark, MAX_PATH, NULL, NULL)) { // TRACE_I("Share: " << netname << " = " << path); - // pridani sharovane cesty do pole Data + // add the shared path to the Data array CSharesItem* item = new CSharesItem(path, netname, remark); if (item != NULL && item->IsGood()) { Data.Add(item); if (Data.IsGood()) - item = NULL; // uspesne pridani + item = NULL; // added successfully else { delete item; Data.ResetState(); Data.DestroyMembers(); - break; // chyba, nema smysl pokracovat v enumu + break; // error, no point in continuing the enumeration } } if (item != NULL) @@ -160,7 +161,7 @@ BOOL CShares::GetWantedIndex(const char* name, int& index) m = (l + r) / 2; char* hw = Wanted[m]->LocalName; int res = StrICmp(hw, name); - if (res == 0) // nalezeno + if (res == 0) // found { index = m; return TRUE; @@ -169,18 +170,18 @@ BOOL CShares::GetWantedIndex(const char* name, int& index) { if (res > 0) { - if (l == r || l > m - 1) // nenalezeno + if (l == r || l > m - 1) // not found { - index = m; // mel by byt na teto pozici + index = m; // should be at this position return FALSE; } r = m - 1; } else { - if (l == r) // nenalezeno + if (l == r) // not found { - index = m + 1; // mel by byt az za touto pozici + index = m + 1; // should be after this position return FALSE; } l = m + 1; @@ -192,14 +193,14 @@ BOOL CShares::GetWantedIndex(const char* name, int& index) void CShares::PrepareSearch(const char* path) { HANDLES(EnterCriticalSection(&CS)); - // vyprazdnime pole Wanted + // empty the Wanted array Wanted.DestroyMembers(); - // zaradime do nej pouze ty shary, ktere lezi na pozadovane ceste + // put in only the shares that lie on the requested path char buff[MAX_PATH]; lstrcpyn(buff, path, MAX_PATH); - if (buff[0] != 0) // pokud hledame shary z this_computer nesmime pripojit backslash - SalPathAddBackslash(buff, MAX_PATH); // na konci chceme backslash + if (buff[0] != 0) // when we search for shares from this_computer, we must not append a backslash + SalPathAddBackslash(buff, MAX_PATH); // we want a backslash at the end int pathLen = (int)strlen(buff); int i; @@ -210,7 +211,7 @@ void CShares::PrepareSearch(const char* path) if (pathLen == itemNameLen && StrNICmp(item->LocalPath, buff, itemNameLen) == 0) { int index; - if (!GetWantedIndex(item->LocalName, index)) // odpovidajici share zaradime do pole Wanted jen pokud jiz tam neni + if (!GetWantedIndex(item->LocalName, index)) // add the matching share to Wanted array only if it is not already there { Wanted.Insert(index, item); } @@ -233,9 +234,9 @@ BOOL CShares::GetUNCPath(const char* path, char* uncPath, int uncPathMax) HANDLES(EnterCriticalSection(&CS)); char buff[MAX_PATH]; lstrcpyn(buff, path, MAX_PATH); - SalPathAddBackslash(buff, MAX_PATH); // na konci chceme backslash + SalPathAddBackslash(buff, MAX_PATH); // we want a backslash at the end - int longestIndex = -1; // index do pole Data, kde lezi nejdelsi vyhovujici share + int longestIndex = -1; // index into Data array holding the longest matching share int i; for (i = 0; i < Data.Count; i++) @@ -244,7 +245,7 @@ BOOL CShares::GetUNCPath(const char* path, char* uncPath, int uncPathMax) int itemNameLen = (int)strlen(item->LocalPath); if (StrNICmp(buff, item->LocalPath, itemNameLen) == 0) { - // hledame nejdelsi mozny share, ktery jeste odpovida pozadovane 'path' + // look for the longest possible share that still matches the requested 'path' if (longestIndex == -1 || (int)strlen(Data[longestIndex]->LocalPath) < itemNameLen) longestIndex = i; } @@ -252,24 +253,24 @@ BOOL CShares::GetUNCPath(const char* path, char* uncPath, int uncPathMax) if (longestIndex != -1) { CSharesItem* item = Data[longestIndex]; - // vlozime nazev naseho pocitace + // insert the name of our computer char unc[2 * MAX_PATH]; strcpy(unc, "\\\\"); DWORD len = MAX_PATH; GetComputerName(unc + 2, &len); strcat(unc, "\\"); - // pripojime nazev sharu + // append the share name strcat(unc, item->RemoteName); - SalPathAddBackslash(unc, 2 * MAX_PATH); // na konci chceme backslash - // z puvodni cesty pripojime adresare od sdileni dale + SalPathAddBackslash(unc, 2 * MAX_PATH); // we want a backslash at the end + // from the original path, append the directories starting from the share if (strlen(item->LocalPath) < strlen(path)) { const char* s = path + strlen(item->LocalPath); if (*s == '\\') - s++; // preskocime pripadny backslash + s++; // skip an optional backslash strcat(unc, s); } - if (!SalGetFullName(unc)) // root "c:\\", ostatni bez '\\' na konci + if (!SalGetFullName(unc)) // root "c\\", others without the trailing '\\' at the end { TRACE_E("Unexpected path in CSharesItem::GetUNCPath()"); HANDLES(LeaveCriticalSection(&CS));