Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/xdg-utils/tests/include/tempfile.sh

Issue 151098: Patch from mdm@google.com... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/xdg-utils/tests/include/tempfile.sh
===================================================================
--- third_party/xdg-utils/tests/include/tempfile.sh (revision 0)
+++ third_party/xdg-utils/tests/include/tempfile.sh (revision 0)
@@ -0,0 +1,47 @@
+## Created 7/14/2006 by Tom Whipple <tom.whipple@intel.com>
+
+## create a globally unique identifier (GUID)
+## note that this is LIKELY to be unique, but not 100% guaranteed.
+get_guid() {
+ prefix=$1
+ now=`date '+%F-%H%M%S.%N'`
+ GUID="$prefix$now-$RANDOM"
+}
+
+get_tmpsubdir() {
+ if [ ! -z "$1" ] ; then
+ tmp="$1"
+ else
+ tmp=${TMPDIR-/tmp}
+ fi
+ if [ -z "$GUID" ] ; then
+ get_guid
+ fi
+ TMPSUBDIR="$tmp/$GUID-$$"
+ (umask 000 && mkdir -p $TMPSUBDIR) || {
+ echo "Could not create temporary directory!" >&2
+ exit 255
+ }
+}
+
+get_shortid() {
+ seqfile=$1
+
+ today=`date '+%m-%d'`
+
+ if [ -f "$seqfile" ] ; then
+ seqdate=`cat $seqfile | cut -d '+' -f 1 -`
+ if [ "$today" = "$seqdate" ] ; then
+ seq=$(( `cat $seqfile | cut -d '+' -f 2 -` + 1 ))
+ else
+ seq=1
+ fi
+ else
+ seq=1
+ fi
+
+ SHORTID="$today+$seq"
+ echo "$SHORTID" > "$seqfile"
+
+}
+
« no previous file with comments | « third_party/xdg-utils/tests/include/system_info ('k') | third_party/xdg-utils/tests/include/testassertions.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698