| 50 | } |
| 51 | |
| 52 | int PU::ExternalToLocalPath(const char * external, TCHAR * local, int localsize) { |
| 53 | if (!external || !local || localsize == 0) |
| 54 | return -1; |
| 55 | |
| 56 | int i = 0; |
| 57 | bool converted = false; |
| 58 | |
| 59 | TCHAR * transformed = SU::Utf8ToTChar(external); |
| 60 | |
| 61 | for(i = 0; i < localsize; i++) { |
| 62 | if (transformed[i] == 0) { |
| 63 | local[i] = 0; |
| 64 | break; |
| 65 | } |
| 66 | |
| 67 | if (transformed[i] == TEXT('/')) { //replace path separators |
| 68 | local[i] = TEXT('\\'); |
| 69 | } else if (!IsValidLocalChar(transformed[i])) { //replace invalid chars |
| 70 | //TODO: try to add substitution here which could be transformed back in LocalToExternalPath() above |
| 71 | //TODO: e.g. unicode point like in xml &#nnnn; |
| 72 | //TODO: problem of buffer size needs to be taken into account which maybe needs a change to use dynamic memory |
| 73 | //TODO: see https://github.com/ashkulz/NppFTP/issues/193 |
| 74 | local[i] = TEXT('_'); |
| 75 | converted = true; |
| 76 | } else { |
| 77 | local[i] = transformed[i]; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | if (i == localsize) |
| 82 | return -1; |
| 83 | |
| 84 | return converted?1:0; |
| 85 | } |
| 86 | |
| 87 | const char* PU::FindExternalFilename(const char * externalpath) { |
| 88 | if (!externalpath) |
nothing calls this directly
no outgoing calls
no test coverage detected