akmal
akmal

Reputation: 665

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!

Upvotes: 3

Views: 66

Answers (1)

Eran Zimmerman Gonen
Eran Zimmerman Gonen

Reputation: 4507

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.

Upvotes: 1

Related Questions