Maybe its better to use the symfon2 Filesystem component.