comparison src/DLD-FUNCTIONS/urlwrite.cc @ 10066:2cd940306a06

make unwind_protect frames local
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 06 Jan 2010 13:18:41 +0100
parents 57b41617c9fd
children 81e88250bf42
comparison
equal deleted inserted replaced
10065:64a06079cae4 10066:2cd940306a06
802 { 802 {
803 error ("urlwrite: unable to open file"); 803 error ("urlwrite: unable to open file");
804 return retval; 804 return retval;
805 } 805 }
806 806
807 unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame (); 807 unwind_protect_safe frame;
808 808
809 unwind_protect::add_fcn (cleanup_urlwrite, filename); 809 frame.add_fcn (cleanup_urlwrite, filename);
810 810
811 bool res; 811 bool res;
812 curl_handle curl = curl_handle (url, method, param, ofile, res); 812 curl_handle curl = curl_handle (url, method, param, ofile, res);
813 813
814 ofile.close (); 814 ofile.close ();
815 815
816 if (!error_state) 816 if (!error_state)
817 unwind_protect::discard_frame (uwp_frame); 817 frame.discard ();
818 else 818 else
819 unwind_protect::run_frame (uwp_frame); 819 frame.run ();
820 820
821 if (nargout > 0) 821 if (nargout > 0)
822 { 822 {
823 if (res) 823 if (res)
824 { 824 {
1424 1424
1425 curl.cwd (dir); 1425 curl.cwd (dir);
1426 1426
1427 if (! error_state) 1427 if (! error_state)
1428 { 1428 {
1429 unwind_protect::frame_id_t uwp_frame = 1429 unwind_protect_safe frame;
1430 unwind_protect::begin_frame (); 1430
1431 1431 frame.add_fcn (reset_path, curl);
1432 unwind_protect::add_fcn (reset_path, curl);
1433 1432
1434 std::string realdir = base.length() == 0 ? dir : base + 1433 std::string realdir = base.length() == 0 ? dir : base +
1435 file_ops::dir_sep_str () + dir; 1434 file_ops::dir_sep_str () + dir;
1436 1435
1437 dir_entry dirlist (realdir); 1436 dir_entry dirlist (realdir);
1489 } 1488 }
1490 } 1489 }
1491 else 1490 else
1492 error ("__ftp_mput__: can not read the directory ""%s""", 1491 error ("__ftp_mput__: can not read the directory ""%s""",
1493 realdir.c_str()); 1492 realdir.c_str());
1494
1495 unwind_protect::run_frame (uwp_frame);
1496 } 1493 }
1497 1494
1498 return retval; 1495 return retval;
1499 } 1496 }
1500 #endif 1497 #endif
1600 { 1597 {
1601 curl.cwd (dir); 1598 curl.cwd (dir);
1602 1599
1603 if (! error_state) 1600 if (! error_state)
1604 { 1601 {
1605 unwind_protect::frame_id_t uwp_frame = 1602 unwind_protect_safe frame;
1606 unwind_protect::begin_frame (); 1603
1607 1604 frame.add_fcn (reset_path, curl);
1608 unwind_protect::add_fcn (reset_path, curl); 1605
1609 1606 string_vector sv = curl.list ();
1610 string_vector sv = curl.list ();
1611 1607
1612 for (octave_idx_type i = 0; i < sv.length (); i++) 1608 for (octave_idx_type i = 0; i < sv.length (); i++)
1613 { 1609 {
1614 time_t ftime; 1610 time_t ftime;
1615 bool fisdir; 1611 bool fisdir;
1630 { 1626 {
1631 error ("__ftp_mget__: unable to open file"); 1627 error ("__ftp_mget__: unable to open file");
1632 break; 1628 break;
1633 } 1629 }
1634 1630
1635 unwind_protect::frame_id_t uwp_frame2 = 1631 unwind_protect_safe frame2;
1636 unwind_protect::begin_frame (); 1632
1637 1633 frame2.add_fcn (delete_file, realfile);
1638 unwind_protect::add_fcn (delete_file, realfile);
1639 1634
1640 curl.get (sv(i), ofile); 1635 curl.get (sv(i), ofile);
1641 1636
1642 ofile.close (); 1637 ofile.close ();
1643 1638
1644 if (!error_state) 1639 if (!error_state)
1645 unwind_protect::discard_frame (uwp_frame2); 1640 frame2.discard ();
1646 else 1641 else
1647 unwind_protect::run_frame (uwp_frame2); 1642 frame2.run ();
1648 } 1643 }
1649 1644
1650 if (error_state) 1645 if (error_state)
1651 break; 1646 break;
1652 } 1647 }
1653
1654 unwind_protect::run_frame (uwp_frame);
1655 } 1648 }
1656 } 1649 }
1657 } 1650 }
1658 #endif 1651 #endif
1659 1652
1711 { 1704 {
1712 error ("__ftp_mget__: unable to open file"); 1705 error ("__ftp_mget__: unable to open file");
1713 break; 1706 break;
1714 } 1707 }
1715 1708
1716 unwind_protect::frame_id_t uwp_frame = 1709 unwind_protect_safe frame;
1717 unwind_protect::begin_frame (); 1710
1718 1711 frame.add_fcn (delete_file, target + sv(i));
1719 unwind_protect::add_fcn (delete_file, target + sv(i));
1720 1712
1721 curl.get (sv(i), ofile); 1713 curl.get (sv(i), ofile);
1722 1714
1723 ofile.close (); 1715 ofile.close ();
1724 1716
1725 if (!error_state) 1717 if (!error_state)
1726 unwind_protect::discard_frame (uwp_frame); 1718 frame.discard ();
1727 else 1719 else
1728 unwind_protect::run_frame (uwp_frame); 1720 frame.run ();
1729 } 1721 }
1730 1722
1731 if (error_state) 1723 if (error_state)
1732 break; 1724 break;
1733 } 1725 }