| 1 | package Net::Amazon::MechanicalTurk::OSUtil; | ||
| 2 | |||
| 3 | our $VERSION = '1.00'; | ||
| 4 | |||
| 5 | sub homeDirectory { | ||
| 6 | my $homeDir; | ||
| 7 | eval { | ||
| 8 | # Looks up home directory for effective user id | ||
| 9 | $homeDir = [getpwuid($>)]->[7]; | ||
| 10 | }; | ||
| 11 | if ($@) { | ||
| 12 | # getpwuid doesn't seem to work on ActivePerl | ||
| 13 | # Try using the Windows API to get the home directory. | ||
| 14 | eval { | ||
| 15 | require Win32; | ||
| 16 | $homeDir = Win32::GetFolderPath(Win32::CSIDL_PROFILE()); | ||
| 17 | }; | ||
| 18 | } | ||
| 19 | return $homeDir; | ||
| 20 | } | ||
| 21 | |||
| 22 | return 1; |