ApplyFileMask: removed limitation of result length, fixed violation of constness