# HG changeset patch # User Adam Chlipala # Date 1240758445 14400 # Node ID ee2feab275dbf51e489d33f8984cb02cda83647c # Parent 1ef3c1ef617d4ddc54ee0933dac77412f56649cb blobSize diff -r 1ef3c1ef617d -r ee2feab275db include/urweb.h --- a/include/urweb.h Sun Apr 26 10:54:45 2009 -0400 +++ b/include/urweb.h Sun Apr 26 11:07:25 2009 -0400 @@ -169,5 +169,6 @@ uw_Basis_string uw_Basis_fileName(uw_context, uw_Basis_file); uw_Basis_string uw_Basis_fileMimeType(uw_context, uw_Basis_file); uw_Basis_blob uw_Basis_fileData(uw_context, uw_Basis_file); +uw_Basis_int uw_Basis_blobSize(uw_context, uw_Basis_blob); __attribute__((noreturn)) void uw_return_blob(uw_context, uw_Basis_blob, uw_Basis_string mimeType); diff -r 1ef3c1ef617d -r ee2feab275db lib/ur/basis.urs --- a/lib/ur/basis.urs Sun Apr 26 10:54:45 2009 -0400 +++ b/lib/ur/basis.urs Sun Apr 26 11:07:25 2009 -0400 @@ -524,6 +524,7 @@ type mimeType val blessMime : string -> mimeType val returnBlob : t ::: Type -> blob -> mimeType -> transaction t +val blobSize : blob -> int con radio = [Body, Radio] val radio : formTag string radio [] diff -r 1ef3c1ef617d -r ee2feab275db src/c/urweb.c --- a/src/c/urweb.c Sun Apr 26 10:54:45 2009 -0400 +++ b/src/c/urweb.c Sun Apr 26 11:07:25 2009 -0400 @@ -2183,6 +2183,10 @@ return f.type; } +uw_Basis_int uw_Basis_blobSize(uw_context ctx, uw_Basis_blob b) { + return b.size; +} + uw_Basis_blob uw_Basis_fileData(uw_context ctx, uw_Basis_file f) { return f.data; } diff -r 1ef3c1ef617d -r ee2feab275db tests/blob.ur --- a/tests/blob.ur Sun Apr 26 10:54:45 2009 -0400 +++ b/tests/blob.ur Sun Apr 26 11:07:25 2009 -0400 @@ -12,8 +12,8 @@ main () and main () = - ls <- queryX (SELECT t.Id, t.Desc FROM t ORDER BY t.Desc) - (fn r =>
  • {[r.T.Desc]}
  • ); + ls <- queryX (SELECT t.Id, t.Desc, t.Data FROM t ORDER BY t.Desc) + (fn r =>
  • {[r.T.Desc]} ({[blobSize r.T.Data]})
  • ); return {ls}