Optimize getContentDirectory

use memory access unstead of string
use char* instead of math calculations