Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a good interface for functions which works with paths

I have functions which get file path as their input argument. This functions are cross platform. Functions support both unicode and regular file paths. What is the best interface for this functions, know I have 2 chooses:

  1. make two version of each function FunctionW and FunctionA as in WinAPI.
  2. make one version which will get char * as input argument, but this string must be in UTF8 format.

Which one is better?

Thanks in advance!

like image 431
akmal Avatar asked Mar 20 '26 05:03

akmal


1 Answers

This really depends on the rest of your code and how you're going to use them. There is no correct answer here - try to approximate the time it will take you to write, to use and to maintain each one of the options, and try to take the one where it's easier.
You should also consider the difference between FunctionA and FunctionW. If the difference isn't big, then you can likely use a single inner helper function that both of them will call, and so the extra time for writing and maintaining a second function is minimal. If it is, consider how tough it would be (if at all) to convert strings to UTF8 for the 2nd option you presented.

like image 148
Eran Zimmerman Gonen Avatar answered Mar 22 '26 01:03

Eran Zimmerman Gonen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!