| 1792 | |
| 1793 | #if defined(UNIX) || defined(WIN_NT) |
| 1794 | int API_ROUTINE gds__edit(const TEXT* file_name, USHORT /*type*/) |
| 1795 | { |
| 1796 | /************************************** |
| 1797 | * |
| 1798 | * g d s _ $ e d i t |
| 1799 | * |
| 1800 | ************************************** |
| 1801 | * |
| 1802 | * Functional description |
| 1803 | * Edit a file. |
| 1804 | * |
| 1805 | **************************************/ |
| 1806 | string editor; |
| 1807 | |
| 1808 | #ifndef WIN_NT |
| 1809 | if (!fb_utils::readenv("VISUAL", editor) && !fb_utils::readenv("EDITOR", editor)) |
| 1810 | editor = "vi"; |
| 1811 | #else |
| 1812 | if (!fb_utils::readenv("EDITOR", editor)) |
| 1813 | editor = "Notepad"; |
| 1814 | #endif |
| 1815 | |
| 1816 | struct STAT before; |
| 1817 | os_utils::stat(file_name, &before); |
| 1818 | // The path of the editor + the path of the file + quotes + one space. |
| 1819 | // We aren't using quotes around the editor for now. |
| 1820 | TEXT buffer[MAXPATHLEN * 2 + 5]; |
| 1821 | fb_utils::snprintf(buffer, sizeof(buffer), "%s \"%s\"", editor.c_str(), file_name); |
| 1822 | |
| 1823 | FB_UNUSED(system(buffer)); |
| 1824 | |
| 1825 | struct STAT after; |
| 1826 | os_utils::stat(file_name, &after); |
| 1827 | |
| 1828 | return (before.st_mtime != after.st_mtime || before.st_size != after.st_size); |
| 1829 | } |
| 1830 | #endif |
| 1831 | |
| 1832 | |