Thermodynamical Theory of Directed Curves