Check required directory structure on module install/enable I am working on a drupal 7 module which acts as a interface for real estates. The interface works with xml files. Because of this i need some folder in the private files system.

I have defined my required folders as constants in the .module file. Now i wanted test with file_prepare_directory if the folders exist and if not create them. I want to do this on module install (hook_requirements) because the module works in the background with crons, so i would never get an error message if there is something wrong with the folder structure. The problem is that i could not access the constants from the .module file in the hook_requirements function.

So what is the best way to do this in drupal 7? Should i use hook_requirements, and if yes, how could i get my constants working? Or is there an ever better way to do this?
The Drupal API function drupal_load() will let you preload your .module file so you can make its constants/functions available during your hook_requirements() invocation:

/**
 * Implements hook_requirements().
 */
function MYMODULE_requirements($phase) {

  // @TODO: misc code.

  drupal_load('module', 'MYMODULE');

  // @TODO: code that requires MYMODULE_CONST_DEFINITION
}