# HCwin32.def: Windows Specific Code # $Id: HCwin32.def,v 1.9 2009/02/14 19:00:13 mschenke Exp $ # ARCS: $Header: /u02/webapps/workbench/cvs/RDA_4/src/scripting/lib/modules/HCwin32.def,v 1.9 2009/02/14 19:00:13 mschenke Exp $ # # Change History # 20090214 LDE Add the 'get_df' macro. =head1 NAME HCwin32 - Sub Module Specific to the Windows Operating System =cut # Make the module persistent keep $KEEP_BLOCK,@SHARE_MACROS var @SHARE_MACROS = ('get_df') =head1 DESCRIPTION This module determines the operating system version and its bit size. The following macro is available: =cut import $OS_BIT,$OS_LVL,$OS_NAM,$OS_PLT,$OS_VER var $reg = 'HKLM\Software\Microsoft\Windows NT\CurrentVersion' var $OS_NAM = getRegValue($reg,'ProductName') var $OS_VER = getRegValue($reg,'CurrentVersion') var $OS_LVL = getRegValue($reg,'CSDVersion','No Service Packs installed') var $OS_PLT = 'Windows' if getEnv('SYSTEMROOT') var $sys = last else var ($sys) = command('echo %SystemRoot%') if testDir('d',catDir($sys,'SysWOW64')) var $OS_BIT = 64 else var $OS_BIT = 32 =head2 get_df($dir) This macro returns the number of free KiB on the file system containing the specified directory. =cut if compare('eq',getOsName(),'cygwin') {macro get_df {var ($dir) = @arg var ($lin) = grepCommand(concat('df -k ',quote($dir,'x')),'\s\d+\%') if match($lin,'\s(\d+)\s+\d+\%\s') var ($siz) = last return $siz } } else {macro get_df {var ($fil) = @arg loop $lin (reverse(grepCommand(concat('cmd /C dir /-C ',quote($fil,'x')),\ '^\s+\d+\s'))) {if match($lin,'^\s+\d+\s.*\s(\d+)\s[^\d]+$') {var ($siz) = last var $siz = int(expr('/',$siz,1024)) return $siz } } return undef } } =head1 COPYRIGHT NOTICE Copyright (c) 2002-2009, Oracle. All rights reserved. =head1 TRADEMARK NOTICE Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. =cut